Interrupt queuing in a media controller architecture

ABSTRACT

Described embodiments provide a media controller for servicing contexts corresponding to data transfer requests from host devices. The media controller includes a context generator for generating contexts corresponding to the data transfer requests and a buffer for storing one or more context pointers, each pointer corresponding to a context and an action by a system module associated with the context. A context processor is configured to complete a context when the action by a media controller module associated with the context is complete, remove each pointer from the buffer associated with the completed context, and determine whether an interrupt corresponds to the completed context and removed pointer. If no interrupt corresponds to the completed context, the completed context is cleared. If an interrupt corresponds to the completed context, the interrupt is provided to a master processor and a completed context recycler for recycling the completed context pointer to the context generator.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application claims the benefit of the filing date of U.S.provisional application No. 61/265,109 filed 30 Nov. 2009, the teachingsof which are incorporated herein in their entireties by reference.

The subject matter of this application is related to U.S. patentapplication Ser. No. 12/436,227 filed 6 May 2009, Ser. No. 12/475,710filed 1 Jun. 2009, Ser. No. 12/475,716 filed 1 Jun. 2009, Ser. No.12/477,996 filed 4 Jun. 2009, Ser. No. 12/478,013 filed 4 Jun. 2009,Ser. No. 12/508,879 filed 24 Jul. 2009, Ser. No. 12/508,915 filed 24Jul. 2009, Ser. No. 12/643,471 filed 21 Dec. 2009, Ser. No. 12/649,490filed 30 Dec. 2009, Ser. No. 12/722,828 filed 12 Mar. 2010, Ser. No.12/730,627 filed 24 Mar. 2010, Ser. No. 12/731,631 filed 25 Mar. 2010,Ser. No. 12/767,985 filed 27 Apr. 2010, Ser. No. 12/768,058 filed 27Apr. 2010, Ser. No. 12/769,882 filed 29 Apr. 2010, Ser. No. 12/769,910filed 29 Apr. 2010, Ser. No. 12/873,450 filed 1 Sep. 2010, Ser. No.12/873,512 filed 1 Sep. 2010, Ser. No. 12/873,548 filed 1 Sep. 2010,Ser. No. 12/952,201 filed on 23 Nov. 2010, Ser. No. 12/952,205 filed on23 Nov. 2010, Ser. No. 12/952,207 filed on 23 Nov. 2010, Ser. No.12/952,200 filed on 23 Nov. 2010, and Ser. No. 12/952,202 filed on 23Nov. 2010, the teachings of all of which are incorporated herein intheir entireties by reference.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to memory storage systems and, morespecifically, to a host interface of a media controller.

2. Description of the Related Art

Flash memory is a type of non-volatile memory that is electricallyerasable and re-programmable. Flash memory is primarily used in memorycards and USB flash drives for general storage and transfer of databetween computers and other digital products. Flash memory is a specifictype of electrically erasable programmable read-only memory (EEPROM)that is programmed and erased in large blocks. One commonly employedtype of flash memory technology is NAND flash memory. NAND flash memoryforms the core of the flash memory available today, especially forremovable universal serial bus (USB) storage devices known as USB flashdrives, as well as most memory cards. NAND flash memory exhibits fasterase and write times, requires small chip area per cell, and has highendurance. However, the I/O interface of NAND flash memory does notprovide full address and data bus capability and, thus, generally doesnot allow random access to memory locations.

There are three basic operations for NAND devices: read, write anderase. The read and write operations are performed on a page by pagebasis. Page sizes are generally 2N bytes, where N is an integer, withtypical page sizes of, for example, 2,048 bytes (2 kb), 4,096 bytes (4kb), 8,192 bytes (8 kb) or more per page. Pages are typically arrangedin blocks, and an erase operation is performed on a block by blockbasis. Typical block sizes are, for example, 64 or 128 pages per block.Pages must be written sequentially, usually from a low address to a highaddress. Lower addresses cannot be rewritten until the block is erased.

Other storage devices, such as conventional hard disk drives (HDDs),support additional disk-access operations, such skip-write andskip-read. A skip operation is used for reading or writing relativelyclosely located, but non-contiguous, blocks on an HDD. The devicerequesting the skip-read or skip-write provides a starting logical blockaddress (LBA), a length count of the number of blocks to read/write, anda skip mask. The skip mask comprises a number of bits where each bit inthe mask corresponds to a block offset from the starting block address.A logic ‘1’ bit in the skip mask signifies that the block correspondingto that bit position will be read/written. A logic ‘0’ bit in the skipmask signifies that the block corresponding to that bit position willnot be read/written and will be skipped. The length count comprises thetotal number of blocks to transfer, not the span of the request. Thus,the length count matches the total number of logic ‘1’ bits in the skipmask. HDDs process skip commands at a media layer of the system, forexample corresponding to a layer in the OSI (“Open SystemsInterconnection”) model. A skip operation is useful for reading orwriting several non-contiguous memory locations without issuing separaterequests and requiring additional revolutions of the HDD. Further, onlythe requested data is transferred to or from the HDD.

An HDD is addressed linearly by logical block address (LBA). A hard diskwrite operation provides new data to be written to a given LBA. Old datais over-written by new data at the same physical LBA. NAND flashmemories are accessed analogously to block devices, such as HDDs. NANDdevices address memory linearly by page number. However, each page mightgenerally be written only once since a NAND device requires that a blockof data be erased before new data is written to the block. Thus, for aNAND device to write new data to a given LBA, the new data is written toan erased page that is a different physical page than the pagepreviously used for that LBA. Therefore, NAND devices require devicedriver software, or a separate controller chip with firmware, tomaintain a record of mappings of each LBA to the current page numberwhere its data is stored. This record mapping is typically managed by aflash translation layer (FTL) in software that might generate alogical-to-physical translation table. The flash translation layercorresponds to the media layer of software and/or firmware controllingan HDD.

For consumer applications, HDDs generally have data sectors that aresized in powers of two (e.g. 512 (29) bytes per sector). Flash memoriesstructured with page sizes that are a multiple of the HDD sector sizemight efficiently work with the HDD system by storing multiple entiresectors in a page (e.g. a 4096 byte page can store eight 512 bytesectors). However, enterprise-based HDD systems generally do not usesectors sized by powers of two, but use larger sectors, generally either520 or 528 bytes per sector instead of 512 bytes.

For write operations, NAND devices store the new data for the LBA on anew page, unlike hard disk drives (HDDs) that can rewrite individualphysical sectors. Thus, a NAND device generally requires that a block beerased before new data can be written to the block. Further, asdescribed above, often a NAND device will write new data for a given LBAto an erased page that is a different physical page from the pagepreviously used for that LBA. Thus, NAND devices also generally requirethe device driver software or the separate controller chip periodicallyinitiate a process to erase data that is “stale” or out-of-date.However, NAND device blocks can be erased relatively few times beforedevice failure (typically on the order of 100,000 erasures). Therefore,over the operational life of an SSD, blocks of flash memory will failand become unusable.

Storage device controllers generally interface with one or more hostdevices via one of various host computer interface protocols such as,for example, Serial Advanced Technology Attachment (SATA), in accordancewith the Serial ATA 2.6 Specification (February 2007), hereinafter,“SATA protocol”, available from Serial ATA International Organization,and Serial Attached Small Computer System Interface (SAS), in accordancewith Serial Attached SCSI 1.1 (SAS-1.1, ANSI INCITS 417-2006),hereinafter, “SAS protocol”, available from the InterNational Committeefor Information Technology Standards (INCITS).

SUMMARY OF THE INVENTION

This Summary is provided to introduce a selection of concepts in asimplified form that are further described below in the DetailedDescription. This Summary is not intended to identify key features oressential features of the claimed subject matter, nor is it intended tobe used to limit the scope of the claimed subject matter.

Described embodiments provide a media controller for servicing contextscorresponding to data transfer requests from host devices. The mediacontroller includes a context generator for generating contextscorresponding to the data transfer requests and a buffer for storing oneor more context pointers, each pointer corresponding to a context and anaction by a system module associated with the context. A contextprocessor is configured to complete a context when the action by a mediacontroller module associated with the context is complete, remove eachpointer from the buffer associated with the completed context, anddetermine whether an interrupt corresponds to the completed context andremoved pointer. If no interrupt corresponds to the completed context,the completed context is cleared. If an interrupt corresponds to thecompleted context, the interrupt is provided to a master processor and acompleted context recycler for recycling the completed context pointerto the context generator.

BRIEF DESCRIPTION OF THE DRAWINGS

Other aspects, features, and advantages of the present invention willbecome more fully apparent from the following detailed description, theappended claims, and the accompanying drawings in which like referencenumerals identify similar or identical elements.

FIG. 1 shows a block diagram of a memory storage system, in accordancewith embodiments of the present invention;

FIG. 2 shows a functional block diagram of sub-modules employed by thememory storage system of FIG. 1, in accordance with embodiments of thepresent invention;

FIG. 3 shows a single-port functional block diagram of the hostsubsystem of FIG. 2, in accordance with embodiments of the presentinvention;

FIG. 4 shows additional detail of the command handling and contextmanagement modules of FIG. 3, in accordance with embodiments of thepresent invention;

FIG. 5 shows additional detail of the initiator lookup table of FIG. 4,in accordance with embodiments of the present invention;

FIG. 6 shows additional detail of the tag manager of FIG. 4, inaccordance with embodiments of the present invention;

FIG. 7 shows a flow diagram of a command tag search algorithm for addingcommands to the tag manager of FIG. 4, in accordance with embodiments ofthe present invention;

FIG. 8 shows a flow diagram of a command tag search algorithm fordeleting a command tag from the tag manager of FIG. 4, in accordancewith embodiments of the present invention;

FIG. 9 shows additional detail of the instruction interface of FIG. 3,in accordance with embodiments of the present invention;

FIG. 10 shows additional detail of the consumed context manager of FIG.4, in accordance with embodiments of the present invention;

FIG. 11 shows additional detail of the context free pointer manager ofFIG. 4, in accordance with embodiments of the present invention;

FIG. 12 shows a block diagram of exemplary contexts for a SAS write datatransfer in a media controller operating in accordance with embodimentsof the present invention;

FIG. 13 shows a block diagram of exemplary contexts for a SAS read datatransfer in a media controller operating in accordance with embodimentsof the present invention;

FIG. 14 shows a block diagram of exemplary contexts for a SATA datatransfer in a media controller operating in accordance with embodimentsof the present invention;

FIG. 15 shows a block diagram of contexts that align to chunk boundariesof data stored in a media system operating in accordance withembodiments of the present invention;

FIG. 16 shows a block diagram of one or more data contexts generatedindependently of a context buffer of a media controller, in accordancewith embodiments of the present invention;

FIG. 17 shows an exemplary receive data path of a SATA host subsystemoperating in accordance with embodiments of the present invention;

FIG. 18 shows a flow diagram of context processing for a write datatransfer in accordance with embodiments of the present invention;

FIG. 19 shows an exemplary transmit data path of a SATA host subsystemoperating in accordance with embodiments of the present invention;

FIG. 20 shows a flow diagram of context processing for a read datatransfer in accordance with embodiments of the present invention;

FIG. 21 shows a block diagram of a SAS host subsystem, in accordancewith embodiments of the present invention;

FIG. 22 shows a receive data path of a SAS host subsystem, in accordancewith embodiments of the present invention;

FIG. 23 shows a transmit data path of a SAS host subsystem, inaccordance with embodiments of the present invention;

FIG. 24 shows additional detail of the pending write table of FIG. 3, inaccordance with embodiments of the present invention;

FIG. 25 shows a block diagram of a generic DMA module, in accordancewith embodiments of the present invention;

FIG. 26 shows a block diagram of the receive datapath of FIG. 25, inaccordance with embodiments of the present invention;

FIG. 27 shows a block diagram of a receive datapath adapted to detectand track high priority commands, in accordance with embodiments of thepresent invention; and

FIG. 28 shows a block diagram of a state machine of the instructioninterface of FIG. 3 to process a SATA FPDMA request, in accordance withembodiments of the present invention.

DETAILED DESCRIPTION

As described herein, embodiments of the present invention provide amedia controller for servicing contexts corresponding to data transferrequests from host devices. The media controller includes a contextgenerator for generating contexts corresponding to the data transferrequests and a buffer for storing one or more context pointers, eachpointer corresponding to a context and an action by a system moduleassociated with the context. A context processor is configured tocomplete a context when the action by a media controller moduleassociated with the context is complete, remove each pointer from thebuffer associated with the completed context, and determine whether aninterrupt corresponds to the completed context and removed pointer. Ifno interrupt corresponds to the completed context, the completed contextis cleared. If an interrupt corresponds to the completed context, theinterrupt is provided to a master processor and a completed contextrecycler for recycling the completed context pointer to the contextgenerator.

Table 1 defines a list of acronyms employed throughout thisspecification as an aid to understanding the described embodiments ofthe present invention:

TABLE 1 USB Universal Serial Bus FIFO First-In, First-Out SATA SerialAdvanced Technology I/O Input/Output Attachment SCSI Small ComputerSystem Interface CRC Cyclic Redundancy Check SAS Serial Attached SCSIDIF Data Integrity Field PCI-E Peripheral Component Interconnect PWTPending Write Table Express SoC System-on-Chip FIS File InformationStructure RAM Random Access Memory SOF Start-of-Frame HDD Hard DiskDrive EOF End-of-Frame SSD Solid State Disk FPDMA First Party DMA LLDLow Level Driver AIG Automatic Instruction Generation LBA Logical BlockAddress NAIG Non-Automatic Instruction Generation BAM Buffer AllocationModule MFG Manual Frame Generation DMA Direct Memory Access PIOProgrammed Input/Output GDMA Generic DMA NCQ Native Command Queuing B-CBuffer-Client CCM Consumed Context Manager RXDP Receive Data Path CFPMContext Free Pointer Manager TXDP Transmit Data Path CCQ ConsumedContext Queue EDP Encryption Data Path ILT Initiator Lookup Table CAMContent Addressable Memory WWN World Wide Name RAID Redundant Array ofIndependent Disks ICT Initiator Connection Tag

FIG. 1 shows a block diagram of a media controller operating inaccordance to embodiments of the present invention. As shown, memorystorage system 100 is electrically coupled to communication link 102.Memory storage system 100 includes media controller 104, external RAMbuffer 114, and media 118. Media 118 might be implemented as a SolidState Disk (SSD), Hard Disk Drive (HDD) or hybrid magnetic and solidstate storage system. Communication link 102 is employed forcommunication with one or more external devices, such as a computersystem or networking device, which interface with memory storage system100. Communication link 102 might be a custom-designed communicationlink, or might conform to a standard communication protocol such as, forexample, Small Computer System Interface (“SCSI”), Serial Attached SCSI(“SAS”), Serial Advanced Technology Attachment (“SATA”), UniversalSerial Bus (“USB”), Fibre Channel (“FC”), Ethernet, IEEE 802.11, IEEE802.15, IEEE 802.16, Peripheral Component Interconnect Express (PCI-E),or any other similar interface for connecting a peripheral device to ahost device.

Media controller 104 controls transfer of data between media 118 and anexternal device coupled to communication link 102. Media controller 104might be implemented as a system-on-chip (SoC). Media controller 104might include internal RAM buffer 112 and might also be coupled toadditional external memory, shown as external RAM buffer 114. In anexemplary embodiment, internal RAM buffer 112 comprises 128 kB of staticRAM (SRAM) and external RAM buffer 114 comprises 512 MB of double datarate version 2 dynamic RAM (DDR2 DRAM). RAM buffer 112 might act as acache for processor 116, while RAM buffer 114 might act as a read/writebuffer between media 118 and communication link 102.

Although shown in FIG. 1 as a single media device, media 118 might beimplemented as one or more storage media. For example, media 118 mightbe implemented as an SSD including one or more physical flash silicondies. In some embodiments, host requests might be striped across two ormore of the dies, analogously to hard drives in a redundant array ofindependent disks (RAID), to provide parallel execution. In otherembodiments, each flash die might be configured as a separate,stand-alone flash memory device without data striping. Similarly, media118 might be implemented as one or more physical drives, which might beimplemented as at least one of an SSD, HDD, or a hybrid magnetic andsolid state storage system.

Although shown in FIG. 1 as a single processor, processor 116 might beimplemented by multiple processors. For example, end users of mediacontroller 100 might require higher or lower performance depending ontheir intended application. The performance requirements might affectthe type of processors employed in the SoC, or the number of processorsemployed in the SoC. For example, a lower performance media controlleroperating in accordance with the SATA protocol might employ a single ARMCortex M3 processor while a higher performance media controlleroperating in accordance with the SAS protocol might employ three ARMCortex R4 processors (ARM Cortex processors are by ARM Holdings, plc,Cambridge, UK). Processor 116 includes software and/or firmware asneeded for operation. For embodiments having multiple processors,inter-processor communication might be employed, such as described inrelated U.S. patent application Ser. No. 12/436,227, filed May 6, 2009.

FIG. 2 shows an exemplary functional block diagram of sub-modulesimplemented as software, hardware, or some combination thereof, withinprocessor 116 of media controller 104. As shown in FIG. 2, mediacontroller 104 might employ one or more functional modules, separatinglow-level hardware-specific signal and timing requirements from thehigher-level functionality of the controller as a whole. The modulesmight include Application Programming Interfaces (APIs), which areprotocols or formats used by software to communicate, via hardwarecommunication links, between sub-applications within the software. Asshown, embodiments of media controller 104 might include five mainmodules: host subsystem 201, buffer subsystem 205, media subsystem 209,infrastructure subsystem 213 and buffer allocation module (BAM) 215.Additionally, one or more of the main modules within media controller104 might be partitioned into a high level module (e.g., host layer 204,buffer layer 206, media layer 210, and infrastructure layer 214) and alow level process module (e.g., host LLD 202, buffer LLD 208, media LLD212, and infrastructure LLD 216).

In operation, for example, media controller 104 might receive requestsfor media access from external devices, such as requests for read orwrite operations, from communication link 102. Such requests for accessto media 118 generally include at least one logical block address (LBA)where data should be read or written. For example, the requests could beto read from or write to a i) single media address, ii) a group ofcontiguous media addresses, or iii) a group of non-contiguous mediaaddresses. Received requests are processed by host subsystem 201. Ingeneral, host layer 204 might process higher level host operations(e.g., host command handlers) and host LLD 202 might process lower levelhost operations (e.g., parsing host commands to the host layer).Commands accessing a group of non-contiguous media addresses might beprocessed such as described in related U.S. patent application Ser. No.12/508,915, filed Jul. 24, 2009. One or more received commands might bequeued or tracked as described in related U.S. patent application Ser.No. 12/649,490, filed Dec. 30, 2009.

Media subsystem 209 translates the LBA into a physical address of thedesired data, for example as described in related U.S. patentapplication Ser. No. 12/643,471, filed Dec. 21, 2009, Ser. No.12/769,910, filed Apr. 29, 2010 and Ser. No. 12/769,882, filed Apr. 29,2010. Media subsystem 209 interfaces with buffer subsystem 205. Medialayer 210 might process higher level media operations (e.g.,logical-to-physical address translation), while media LLD 212 mightprocess lower level media operations (e.g. media hardware-specificread/write/erase). Media layer 210 also might enable error recovery andwear-leveling routines for media 118, such as described in related U.S.patent application Ser. No. 12/475,710, filed Jun. 1, 2009, Ser. No.12/475,716, filed Jun. 1, 2009 and Ser. No. 12/508,879, filed Jul. 24,2009. In embodiments of the present invention, media layer 210 mightsupport enterprise system sector sizes (e.g., 520 or 528 bytes persector instead of 512 bytes per sector), such as described in relatedU.S. patent application Ser. Nos. 12/477,996 and 12/478,013, both filedJun. 4, 2009.

Since data transfers between communication link 102 and media 118 mightbe temporarily stored in buffer memory, buffer subsystem 205 generallydirects the data traffic between host subsystem 201 and media subsystem209. For example, if an external host (not shown) provides, viacommunication link 102, data to be written to media 118, buffersubsystem 205 might coordinate temporary storage of the data in buffer114 until media subsystem 209 coordinates writing the data to media 118.Similarly, if the external host requests to read data from media 118,buffer subsystem 205 might temporarily store the data in buffer 114until host layer 204 coordinates sending the data to the host viacommunication link 102.

In general, buffer layer 206 might process higher level buffer and cacheoperations (e.g., cache and buffer allocation), while buffer LLD 208processes lower level buffer operations (e.g., RAM hardware-specificcommands). Buffering of data might occur, for example, as described inrelated U.S. patent application Ser. No. 12/722,828, filed Mar. 12,2010, Ser. No. 12/730,627, filed Mar. 24, 2010, and Ser. No. 12/731,631,filed Mar. 25, 2010. Infrastructure subsystem 213 might generally serveas an operating system for media controller 104, with infrastructurelayer 214 performing higher level processing operations (e.g., operatingsystem operations) and infrastructure LLD 216 performing lower leveloperating system operations (e.g., initialization, timers, interrupts).

As shown in FIG. 2, media controller 104 also includes Buffer AllocationModule (BAM) 215. As shown, BAM 215 is coupled to host layer 204, bufferlayer 206, and infrastructure layer 214. In embodiments of the presentinvention, BAM 215 might be employed to provide acceleration andflexibility in managing one or more cache buffers in RAM buffers 112 and114 and the transfer of information between host layer 204 and bufferlayer 206. For example, BAM 215 might maintain cache management datathat describes data blocks stored in a cache, the status of the datablocks stored in the cache (e.g., valid, dirty, etc.), the physicaladdress of that data, and which modules of media controller 104 areaccessing the data.

As will be described in greater detail below, BAM 215 might typicallyinclude i) a first control sequencer for host command and contextprocessing and ii) a second control sequencer for buffer command andcontext processing. In general, a context is a data structure usedwithin media controller 104 that specifies the information necessary tosend or receive data (e.g., to send a data frame or frame informationstructure (FIS) on communication link 102, to perform direct memoryaccess (DMA), etc.). Since both host subsystem 201 and buffer subsystem205 might access the same cache data structures, BAM 215 includes anarbiter to arbitrate between the first and second control sequencers toguarantee access to cache entries. BAM 215 might be employed to performcache lookup for a command to enhance performance or to process acommand and generate a thread of contexts for that command. BAM 215might also be employed to perform buffer allocation for a context or tomodify fields in a context. Thus, BAM 215 provides flexibility inmanipulating context threads, generating individual contexts, andallocating cache data in the buffer. BAM 215 will be described ingreater detail with regard to FIGS. 12-16.

FIG. 3 shows greater detail of host subsystem 201. As shown, hostsubsystem 201 might typically include link physical layer (PHY) 302 andLink Protocol Core 304 for communication with communication link 102.Host subsystem 201 might receive data and commands from host devicescoupled to communication link 102, with PHY 302 providing an interfaceto the physical transmission media employed by communication link 102and Link Protocol Core 304 controlling the operation of PHY 302 andformatting data into frames in accordance with the protocol employed bycommunication link 102.

Receive Data Path (RXDP) 306 receives incoming data from communicationlink 102 via link protocol core 304. RXDP 306 routes incoming data to i)buffer subsystem 205 (e.g., incoming user data might be temporarilystored in a buffer before being written to media 118) or ii) otherinternal modules of host system 201 (e.g., command handling module 310).RXDP 306 might include buffer 308 for synchronizing data between thetiming requirements of link protocol core 304 and the timingrequirements of host subsystem 201. For example, data might be sent inframes for a given link protocol, and RXDP 306 might reorganize theframed data into data blocks for further processing within mediacontroller 104. RX buffer 308 might be sized to support requiredbandwidth for both the link protocol and the internal communicationswithin media controller 104. Buffer subsystem 205 includes contextbuffer 322. Context buffer 322 might be implemented as one or morefirst-in, first-out (FIFO) linked lists for queuing contexts.

Encryption Data Path (EDP) 316 might perform i) encryption of datareceived by media controller 104 for storage on media 118, and ii)decryption of data stored on media 118 for transmission overcommunication link 102. EDP 316 might be implemented as a pipeline stagein Transmit Data Path (TXDP) 318 such that a first segment of decrypteddata is provided from TXDP 318 to Link Protocol Core 304 while a nextsegment of data is decrypted by EDP 316. EDP 316 might employ anysuitable encryption methodology such as the Advanced Encryption Standard(AES), defined in Federal Information Processing Standard (FIPS)Publication 197. EDP 316 might also employ key management such asdescribed in related U.S. patent application Ser. Nos. 12/767,985 and12/768,058, both filed Apr. 27, 2010.

TXDP 318 transfers outgoing data from media controller 104 tocommunication link 102 via link protocol core 304. Similarly as RXDP306, TXDP 318 might include buffer 320 for synchronizing data betweenthe timing requirements of host subsystem 201 and the timingrequirements of link protocol core 304. Further, TXDP 318 might includea pre-fetch engine for loading data for a next context into TX buffer320 while link protocol core 304 is transmitting data for a previouscontext, to transfer data for multiple contexts without gaps of idletime in link protocol core 304 (and communication link 102). Althoughshown in FIG. 3 as being a single-port system, such as for SATA devices,having a single link protocol core, a single RXDP and a single TXDP,embodiments of the present invention, such as for SAS devices, mightinclude dual link protocol cores, dual RXDPs and dual TXDPs to support2-port communication. Such embodiments will be described subsequently inregard to FIGS. 21-23.

As shown in FIG. 3, host subsystem 201 performs three main functions: i)transferring data between link protocol core 304 and buffer subsystem205, ii) processing received protocol commands (e.g., by commandhandling module 310), and iii) managing and processing contextscorresponding to data transfers (e.g., by context management module312). Command handling module 310 might typically verify a receivedcommand and normalize the received command (e.g., from aprotocol-specific format to a normalized format) and convert the commandinto one or more contexts for processing by media controller 104. Forexample, Link Protocol Core 304 might provide SATA or SAS command framesto command handling module 310, and command handling module 310 mightthen perform checks on the frame. Context management module 312 mighttypically i) execute a thread of contexts corresponding to a datatransfer, ii) manage context pointer lists to provide fast contextloading, and iii) generate interrupts based on the contexts. Instructioninterface 314 might typically process a transmit context to determine acorresponding protocol instruction and convert the context into thespecific protocol instruction for Link Protocol Core 304. Instructioninterface 314 will be described in greater detail in regard to FIG. 9.

Pending Write Table (PWT) 324 maintains a list of active write commandsto media 118. As shown, RXDP 306 is in communication with PWT 324 toprovide PWT 324 with data corresponding to one or more active writecommands in host subsystem 201. For example, RXDP 306 might provide oneor more write contexts corresponding to each active write command. Awrite context corresponds to a data stream being transferred to mediacontroller 104 for storage on media 118. The active write contexts mightbe stored in buffer subsystem 205, for example, context buffer 322. Inembodiments of the present invention, PWT 324 is implemented as one of aRAM memory or a register file. RXDP 306, Transmit Data Path (TXDP) 310,Command Handling module 310, Context Management module 312, and PendingWrite Table 324 might generally provide a context processing pipelinefor host subsystem 201.

FIG. 4 shows greater detail of command handling module 310 and contextmanagement module 312. As shown in FIG. 4, command handling module 310includes Tag Manager 402, Initiator Lookup Table (ILT) 404 and CommandParser (CP) 406.

Command Parser 406 receives host commands from RXDP 306 and provides oneor more contexts to perform the command. New contexts might typically beadded to the tail end of an active context queue, which might be one ofa plurality of linked lists stored in buffer subsystem 205. Each linkedlist has a corresponding a read and write pointer. In operation, CP 406might receive a host command (e.g., a SATA or SAS command) from i) RXDP306 if there are no commands queued in command FIFO 323, or ii) the headof command FIFO 323 if one or more commands are queued. CP 406 tracksthe read and write pointers of the active command queue and might beconfigured to automatically load a next command from RX Buffer 308 whenthe read and write pointers are not equal. The command is loaded to acommand register of CP 406, and might be rewritten in a normalizedformat. For example, control fields that might vary depending on thehost protocol, such as starting LBA and transfer length, might be placedin common command fields. CP 406 might generate an interrupt when avalid and normalized command is ready to be parsed so as to generate oneor more contexts in one or more context registers of CP 406. The one ormore contexts correspond to one or more data transfers internal to mediacontroller 104 to perform the received host command. Once thecorresponding one or more contexts are generated, CP 406 clears the hostcommand from the command register to allow a next host command to beloaded and processed.

Parallel context generation might generally performed by Command Parser406. As described herein, command parser 406 might generate one or morecontexts to satisfy a received command. These contexts might be storedin two or more sets of context registers to store contexts in parallel.In embodiments of the present invention, one set of context registersare reserved for high priority command processing while the other set ofcontext registers are employed for normal command processing. While acommand is being processed, an interrupt might be generated forprocessor 116 to process a subsequent received command that is a higherpriority command. For example, a high priority interrupt might begenerated when a media-side operation completes and a requested datatransfer is available in buffer subsystem 205. Processing is switched tothe high priority interrupt and a context is generated for that routinein the high priority context registers, without disturbing the contextsfor the normal command, which are stored in one of the other parallelset of registers. Thus, command parser 406 returns to the previouscommand processing routine without requiring a large firmware stack forcontexts, because the state of the current context generation process isseparately saved in parallel registers. This parallel context structureallows processor 116 to handle the interrupt and generate contexts forthe high priority command without disturbing command processing for thelower priority command.

ILT 404 is typically used for the enterprise applications to storeinformation for one or more SAS initiators in communication with mediacontroller 104. ILT stores a 64-bit World-Wide Name (WWN) of one or moreinitiators with active connections to media controller 104, the 16-bitInitiator Connection Tag (ICT) corresponding to the active connection,and a count of the number of commands outstanding from each initiator.The WWN is a 64-bit globally unique identifier assigned to a SAS deviceby its manufacturer that uniquely identifies each SAS device. The ICT isa 16-bit number sent to media controller 104 by the SAS initiator. TheICT might be included by media controller 104 in responses to the SASinitiator, such that the SAS initiator can identify media controller104. Each initiator WWN and ICT might be converted to an ILT ID that isincluded in each context for the command to reference back to thecorresponding initiator information in ILT 404.

Embodiments of the present invention provide 8 entries in ILT 404 tosupport 8 concurrent initiators. If another initiator establishes aconnection beyond the maximum of 8 cached in ILT 404, the new initiatormight, for example, receive a Task Set Full or Busy response status, anda connection would be denied. Alternatively, embodiments of the presentinvention might replace an entry in ILT 404 with the new initiator, forexample, if a cached initiator had no outstanding commands with mediacontroller 104. For example, when RXDP 306 receives a command, RXDP 306checks ILT 404 for the initiator. The 64-bit WWN is checked on eachconnection when receiving commands. If the WWN is cached in ILT 404, theILT ID is provided, along with a command tag, to Tag Manager 402. If theinitiator is already in communication with media controller 104, RXDP306 increments the command count in ILT 404 corresponding to thatinitiator. When processing of that command is complete, for example wheninstruction interface 314 sends the response for the command,instruction interface 314 decrements the command count in ILT 404corresponding to that initiator.

ILT 404 also provides an overall SAS command queue counter to track theoverall maximum queue depth of media controller 104 to indicate TASK SETFULL or BUSY when a new command is received. The overall maximum queuedepth is maximum number of active commands allowed be media controller104. As described herein, for embodiments of the present invention, themaximum queue depth of media controller 104 might be 128 activecommands. Typically, BUSY status indicates that ILT 404 cannot acceptthe new command because of a temporary hardware restriction, such ascommand FIFO 323 being full. When an initiator receives a BUSYindication, the initiator might try to send the same command againlater. Typically, TASK SET FULL status indicates that a given initiatorhas reached the hardware limit of active commands for that particularinitiator. When an initiator receives a TASK SET FULL indication, theinitiator might reduce its queue depth to avoid going over the limit ofactive commands for media controller 104.

FIG. 5 shows greater detail of ILT 404. As shown in FIG. 5, ILT 404includes initiator table 502, interrupt interface 510 and arbitrationmodule 512. When a command is received from a SAS initiator via RXDP306, ILT 404 stores information about the initiator in initiator table502. As described herein, the information stored in initiator table 502corresponds to one or more SAS initiators that have commands active inmedia controller 104, and includes, for example, the WWN of each SASinitiator (WWN 504), an initiator connection tag (ICT) of each SASinitiator (ICT 506), and a count of the number of active commands foreach SAS initiator (count 508). In exemplary embodiments, initiatortable 502 maintains information for up to 8 active SAS initiators. TheWWN and ICT for each initiator might be converted to an ILT ID, whichmight be the index of initiator table 502. The ILT IDS is employed incontexts of media controller 104 rather than employing the fullinitiator information stored in initiator table 502 in the contexts.

Upon receiving a command from a SAS initiator, RXDP 306 checks ILT 404to determine whether sufficient resources exist to handle the command.If resources do not exist, then RXDP 306 rejects the command bytransmitting a response of either a TASK SET FULL or BUSY frame viainstruction interface 314. As shown in FIG. 5, when a SAS command isreceived, RXDP 306 provides the WWN and the ICT to ILT 404. ILT 404checks the received WWN against the entries stored in initiator table502. If the received WWN is not already stored in initiator table 502,and there is space available in the table, the received WWN is added toinitiator table 502 in the first available location, along with theinput ICT and count is set to 1 for the received command (shown asentries 504, 506 and 508). If the received WWN is already stored ininitiator table 502, then the existing entry for the initiator is usedand the count entry is incremented to reflect the additional command.ILT 404 returns the ILT ID number, shown as 518, to RXDP 306, and theILT ID is stored in the one or more contexts corresponding to thecommand.

If all entries in initiator table 502 are occupied by other initiators,and each entry has an active command count greater than 0, then ILT 404,via interrupt interface 510, might generate an interrupt to processor116. RXDP 306 might queue the received command until after the interruptis processed. If the initiator table or command FIFO 323 is full, ILT404 might respond to RXDP 306 with a BUSY message, shown as signal 514,to indicate to the initiator that media controller 104 is busy andcannot yet receive the command. When a given initiator reaches itsmaximum allowed commands, ILT 404 might respond to RXDP 306 with theTASK SET FULL message, shown as signal 516, to indicate to the initiatorthat media controller 104 cannot yet receive another command from thatinitiator. After the BUSY or TASK SET FULL status is determined, RXDP306 might then discard the received command.

ILT 404 also might be accessed by instruction interface 314 before theinstruction interface issues a SAS instruction to link protocol core304. As shown in FIG. 5, ILT 404 provides instruction interface 314 withWWN 504 and ICT 506. Instruction interface 314 might provide data to ILT404 as commands are completed, for example, as shown, instructioninterface 314 might provide the ILT ID number of the completed commandand might request that ILT 404 decrement the count of active commandsfor the corresponding initiator in initiator table 502.

As described herein, resource availability might typically be determinedbased upon the total number of commands that have been received and amaximum number of commands allowed in the system, the maximum queuedepth. Embodiments of the present invention might alternatively makethis determination based upon i) a minimum number of commands perinitiator, which prevents any single initiator from being locked outwhile a different initiator consumes all available resources, ii) amaximum number of commands per initiator, which balances availableresources between initiators, and iii) the maximum queue depth of allallowed commands in the system. Embodiments of the present inventionalso provide that the number of active initiators is programmable, andthat the minimum and maximum number of commands per initiator and themaximum queue depth, are also programmable. The number of allowedcommands per initiator is based upon the total number of initiatorssupported, and the total resources available within media controller104. If a smaller number of initiators are supported, then moreresources are made available to each initiator, if appropriate.Resources might be dynamically re-allocated depending upon systemcharacteristics.

For example, during initialization of media controller 104, ILT 404might be set to track information for up to 8 initiators, and themaximum queue depth might be set to 128 total active commands. When 8initiators are supported, the minimum number of commands per initiatormight typically be set in the range between 1 and 4 commands. Themaximum number of commands per initiator might typically be set in therange between 32 and 96 commands. In a specific example, the minimumnumber of commands per initiator is set to 1, and the maximum number ofcommands per initiator is set to 64. In this case, the maximum queuedepth might be set to 122, which would allow a first initiator to useits maximum of 64 commands, and a second initiator to use a maximum of58 commands, while allowing each of the remaining 6 initiators 1 commandup to the maximum 128 active commands. Thus, each of the 8 initiatorswould allowed at least the minimum 1 active command after the first twoimitators have each attempted to use their maximum number of commands.Further, the total number of commands accepted remains within theallowed maximum of 128 active commands.

As a second example, ILT 404 might be set to track information for twoinitiators, and an interrupt is generated if a command from a thirdinitiator is received. Again, the maximum queue depth might be 128commands. Since only two initiators are stored in initiator table 502,the minimum number of commands per initiator might be set to a largernumber, such as 24 commands. The maximum number of commands perinitiator might then be set as 103 (to allow the minimum 24 commands tothe other supported initiator). The total queue depth would be set to128. The advantage in this example is that more resources are allocatedfor one or two initiators, but if commands for more than two initiatorsare received, an interrupt must be generated to allow the command forthe third initiator to be received. To receive the command from thethird initiator, values for the minimum number and maximum number ofcommands that are allowed for each initiator are desirably reconfiguredduring the interrupt processing. Embodiments of the present inventionthus provide flexibility to dynamically allocate resources amongdifferent initiators during operation of media controller 104.

Tag Manager 402 verifies a command tag used to identify active commandsin media controller 104, for example in SATA systems with native commandqueuing or SAS systems with command queuing. Tag Manager 402 verifiesthat a new command tag does not overlap with a command tag that iscurrently active. When RXDP 306 receives a new command, RXDP 306 checksthe command tag table of tag manager 402 before the command is moved outof RX Buffer 308 for processing. In embodiments of the presentinvention, Tag Manager 402 might support one host device with a limit of32 active commands, for example, for SATA systems. In such embodimentsTag Manager 402 might be implemented as a tag table to support the 32active commands. In other embodiments, Tag Manager 402 might supportmultiple host devices and deeper command queues, such as in a SASsystem. In such embodiments Tag Manager 402 might be implemented as aPseudo-CAM (content addressable memory) to support the larger and morecomplex tag memory. Such embodiments might support a maximum of 128active SCSI Command Tags (which might be equal to the maximum queuedepth of media controller 104). FIG. 6 shows greater detail of TagManager 402.

As shown in FIG. 6, tag manager 402 includes pseudo-CAM 606, whichgenerally provides fast access for tag lookup without requiring a largeexternal buffer in SAS systems having queued commands and multipleinitiators. For SATA devices, a simpler tag table, 604, might beemployed instead of pseudo-CAM 606. When a command is received, RXDP 306checks a command tag of the corresponding command and provides thecommand tag to arbitration module 602. Arbitration module 602 generallymanages access to tag manager 402 by processor 116, RXDP 306 andinstruction interface 314. As indicated by the dashed lines, in a SASsystem, arbitration module 602 might also arbitrate access to tagmanager 402 between an instruction interface and an RXDP for a secondport (not shown). Embodiments of the present invention having 2 portswill be described with regard to FIGS. 21-23

When a command is received, RXDP 306 requests access to tag manager 402and provides the tag ID of the received command to arbitration module602, as indicated by Tag ID signal 620. Arbitration module 602 providesthe tag ID to the appropriate one of tag table 604 or pseudo-CAM 606 toperform a tag lookup. If the Tag ID does not exist in tag table 604 orpseudo-CAM 606, the tag ID is added to the table, and arbitration module602 provides acknowledge signal 618 to RXDP 306. RXDP 306 then moves thereceived command from the RX Buffer 308, for example to buffer subsystem205. As described herein, checking the command tag before a receivedcommand is moved from RX Buffer 308 simplifies error handling on tagerror cases because processing of the received command is not yetstarted. If the received tag ID already exists in tag table 604 orpseudo-CAM 606, a tag overlap condition exists, and an interrupt isgenerated to processor 116 to perform additional processing to handlethe error condition.

Instruction interface 314 might generally delete a command tag aftersending the data corresponding to the received command. Instructioninterface might send DELETE TAG signal 610 and TAG ID signal 612 toarbitration module 602. When arbitration module responds with ACK Signal614 after the command tag has been deleted, instruction interface 314might clear the related command contexts. In embodiments of the presentinvention, the number of stored command tags is equal to the currentnumber of active commands (the command queue depth). As describedherein, in some embodiments, a desired maximum command queue depth mightbe 128 (i.e., a maximum of 128 active commands supported).

Pseudo-CAM 606 might support one or more different hash algorithms.Different hash algorithms might be chosen to provide support fordifferent numbers of active initiators and command queue depths for eachinitiator. Desirably, the hash algorithm distributes the initial searchaddress across all addresses of pseudo-CAM 606. Embodiments of thepresent invention support 4 hash modes. Each hash mode provides an 8-bitoutput address. The first hash mode does not necessarily account for theinitiator ID when searching pseudo-CAM 606, which might be preferred forsingle-initiator systems. The second hash mode might provide 1 bit ofthe 8-bit output to account for the initiator ID, which might bepreferred for two initiator systems. Similarly, the third hash modemight provide 2 bits of the 8-bit output to account for the initiatorID, which might be preferred for four initiator systems, and the fourthhash mode might provide 3 bits of the 8-bit output to account for theinitiator ID, which might be preferred for eight initiator systems. Inexemplary embodiments, the first hash mode might employ the hashalgorithm Hash=Tag ID[0:7]; the second hash mode might employ the hashalgorithm Hash={initiator ID[0], Tag ID[0:6]}; the third hash mode mightemploy the hash algorithm Hash={initiator ID[0:1], Tag ID[0:5]}; and thefourth hash mode might employ the hash algorithm Hash={initiatorID[0:2], Tag ID[0:4]}.

Pseudo-CAM 606 might generally include registers or memory locations tostore the command tags in a tag table. Processor 116 might add or deletetags, or clear the entire table, using a control register. Inembodiments of the present invention, each register or memory locationis 32-bits. Within each 32-bit memory location, one or more bits mightindicate a VALID status that, when set, includes that location in thepseudo-CAM search. When the VALID status is not set, the location is notincluded in the pseudo-CAM search. A second group of one or more bitsmight indicate a TAG COUNT that indicates a number of entries to bechecked in the search. A third group of one or more bits might store theILT ID number used to reference the SAS initiator. A fourth group of oneor more bits might store the TAG ID representing the SCSI command tag.This general data structure is employed in performing tag searches whena new command is received by RXDP 306. The tag search operation isdescribed in greater detail in regard to FIGS. 7 and 8.

FIG. 7 shows a flow diagram of command tag search algorithm 700 forreceiving a command and adding the command tag to tag manager 402. Asshown, at step 702, a SAS command is received in RX Buffer 308. The SCSICommand Tag is parsed from the received command and is provided to RXDP306. At step 704, RXDP 306 provides the Initiator ID (e.g., theinitiator's WWN) to ILT 404. At step 706, the 64-bit WWN is encoded toan ILT ID used internally by media controller 104. The ILT ID and the16-bit SCSI Command Tag are combined to form the tag ID, which isprovided to tag manager 402.

At step 708, Tag Manager 402 performs a hash function to convert the tagID to a starting search address of pseudo-CAM 606. At step 710, tagmanager 402 reads TAG COUNT from the starting address location. Asdescribed, TAG COUNT provides the number of entries stored in the tagtable that is searched to determine if a tag overlap exists. At step712, if TAG COUNT is equal to zero, no tag overlap is detected and thesearch is complete. Algorithm 700 proceeds to step 734 and adds the newtag ID to pseudo-CAM 606. The new tag ID is stored in the first invalidentry of pseudo-CAM 606, which was stored at step 718. The TAG COUNT forthis address of pseudo-CAM 606 is not changed. Once the tag ID is storedto pseudo-CAM 606, algorithm 700 completes at step 736. This algorithmminimizes the search depth since the entries for a hash are clustered bythe starting hash address.

If the TAG COUNT is non-zero, the search continues at step 714. At step714, the address is read from pseudo-CAM 606. At step 716, the VALIDflag of the read address entry is checked. If the entry is not valid,and no other non-valid entry has been detected, at step 718 the addressof the invalid entry is stored to add the tag ID, and processingcontinues to step 720. Thus, at step 718, the first invalid entry ofpseudo-CAM 606 is found and its address stored. At step 720, the TAGCOUNT is decremented. At step 722, the address of pseudo-CAM 606 isincremented and processing returns to step 710. At step 716, if theentry is valid, processing continues at step 724. At step 724, the tagID stored at the address is read.

At step 726, Tag Manager 402 compares the read tag ID with the new tagID. If the read tag ID matches the new tag ID, then at step 728 anoverlap error is detected and an error interrupt is generated. The tagsearch is ended at step 736. If the read tag ID does not match the newtag ID, the process continues to step 730. At step 730, tag manager 402performs the hash algorithm on the read tag ID and at step 732, thehashed read tag ID is compared with the starting search address (i.e.the hashed new tag ID). At step 732, if the hashed read tag ID matchesthe starting search address, the TAG COUNT is decremented at step 720.If the hashed read tag ID does not match the starting search address,TAG COUNT is unchanged and the address is incremented at step 722. Theprocess continues until the TAG COUNT reaches zero or a tag overlap isdetected.

FIG. 8 shows a flow diagram of command tag search algorithm 800 forcompleting a command and deleting the associated command tag from tagmanager 402. At step 802, command tag search algorithm 800 is initiatedwhen a SAS Command is completed by media controller 104 (i.e. when a SASresponse frame is transmitted for the command). At step 804, thecompleted tag ID is provided to tag manager 402 to be removed frompseudo-CAM 606 and later reused by the SAS initiator. At step 806, tagmanager 402 performs the hash function to convert the completed tag IDto a starting address of pseudo-CAM 606. At step 808, tag manager 402reads the TAG COUNT corresponding to the address. The TAG COUNTdetermines how many addresses need to be searched to determine if a tagoverlap exists.

At step 810, if the TAG COUNT is equal to zero, no entry matching thecompleted tag ID exists in pseudo-CAM 606. This is an error condition,since the tag ID should exist if it was completed, and thus no entry canbe deleted. At step 812, the error condition is detected and aninterrupt is generated. The tag search and deleted operation is ended atstep 832. At step 810, if the TAG COUNT is non-zero, the searchcontinues to step 814. At step 814, the address of pseudo-CAM 606 isread. At step 816 the entry valid bit is checked. If the entry is notvalid, at step 818 the address of pseudo-CAM 606 is incremented andprocessing returns to step 808. If, at step 816, the entry is valid,processing continues to step 820.

At step 820, tag manager 402 reads the tag ID stored at the address inpseudo-CAM 606. At step 822, tag manager 402 compares the read tag IDwith the completed tag ID. If the read tag ID matches the completed tagID, then the proper entry has been located and processing proceeds tostep 824. At step 824, tag manager 402 clears the valid bit for theentry, but preserves the TAG COUNT for that address of pseudo-CAM 606.The tag entry has been removed from future tag searches and is availableto be reused for future commands. The process is complete at step 832.

If, at step 822, the read tag ID does not match the completed tag ID,the process continues to step 828. At step 828, tag manager 402 performsthe hash algorithm on the read tag ID to provide a hashed read tag. Atstep 828, the hashed read tag is compared with the starting searchaddress. If the hashed read tag matches the starting search address, atstep 830 the TAG COUNT is decremented and the process continues to step818. If, at step 828, the hashed read tag does not match the startingsearch address, the TAG COUNT unchanged and the process continues tostep 818. The process continues until TAG COUNT reaches zero or a tagerror is detected.

FIG. 9 shows a block diagram of instruction interface 314. For SATAcommands, SATA Protocol Assist Module 904 generates a SETUP FIS andcounts a total amount of data transferred, decoupling the SATA protocolrequirements from data transfer context boundaries. SATA Protocol AssistModule 904 maintains DMA Setup counter 902. DMA Setup counter 902 tracksframe boundaries for the overall data transfer. The contextconfiguration bits indicate how the context should be routed andhandled. For SAS commands, SAS Protocol Assist Module 906 generates aTRANSFER READY frame for commands. The overall data count is maintainedin Pending Write Table (PWT) 324. RXDP 306 (for reception) and TXDP 318(for transmission) operate on individual data transfer contexts. Theconfiguration of the context indicates how the context should be routedand indicates how RXDP 306 and TXDP 318 should handle contextboundaries. RXDP 306 and TXDP 318 track the context boundary count andload a new context to support scatter-gather operation and continue thetransfer without affecting the protocol operation. Instruction control908 might generally include a state machine to perform the operations ofinstruction interface 314. Instruction registers 910 might be used toautomatically generate responses (e.g., a SETUP or RESPONSE frame) fortransmission over communication link 102, such as described in regard toAutomatic Instruction Generation mode of media controller 104 (FIG. 28).

Referring back to FIG. 4, context management module 312 includes ContextCache (CC) 408, Consumed Context Manager (CCM) 410 and Context FreePointer Manager (CFPM) 412.

Context cache 408 loads contexts from context buffer 322 to perform thedata transfer corresponding to the context. As described herein, one ormore contexts correspond to a data transfer for a host command. Contextcache 408 might include one or more context pointers to read contextsfrom one of context buffer 322 or BAM 215. Context cache 408 mightprovide retrieved contexts to one or more of instruction interface 314,TXDP 318, and PWT 324 for further processing. For example, context cache408 stages retrieved contexts at the head of the active context queue inTXDP 318 before previous contexts complete execution. Context cache 408might stage a next context by modifying one or more contexts before theyare executed, or reordering the active context queue. For example, theactive context queue might typically include pointers to the nextcontext to be executed, thus linking the contexts together in a linkedlist. The pointer to the next context in the list is generated when thecontexts are generated, thus defining the order of the linked list ofcontexts. Context Cache 408 thus allows the priority of a thread to bechanged dynamically, for example, by modifying or reordering contexts inthe active context queue before the data transfer corresponding to thecontext is started.

In embodiments of the present invention, context cache 408 might includeparallel context linked lists to store context pointers from parallelcontext processing threads. For example, context cache 408 might employone parallel context thread as a normal-priority context thread and oneparallel context thread as a high-priority context thread. The priorityof a context thread might be indicated by a control bit. Context cache408 might typically process the normal-priority context thread until oneor more contexts are present in the high-priority thread. When thenormal-priority context thread reaches a protocol boundary (e.g., aframe boundary), context cache 408 might pause the normal-prioritythread and process the contexts of the high-priority thread. Theprotocol boundary might be indicated by a context control bit signifyingthat the context being processed is the last context for a givenprotocol unit. For SATA, switching execution to the priority threadmight typically be allowed at a Setup boundary since the device hascommitted to transferring that amount of data before switching toanother thread. For SAS, switching might be allowed at the datainstruction (commit amount) boundaries for better efficiency on datatransfers. The high-priority context thread might typically be executeduntil it is empty, and then context cache 408 returns to completeprocessing of the normal-priority context thread.

After a data transfer for a context is completed, the command and datacache information should be updated to maintain the integrity of cachedinformation. In general, embodiments of the present invention mightprovide an interrupt to service a cache update routine. As describedherein, multiple data transfer contexts might be employed for a singlecommand. Thus, embodiments of the present invention provide cache updateinterrupts at data boundaries that are not tied to individual contexts,but rather to entire data transfers. A context interrupt queue might beemployed to allow multiple data transfer contexts to be processed by asingle interrupt. Further, embodiments of the present invention employthe context interrupt queue to allow the cache update interrupt routineto be performed outside of the data transfer performance path, avoidingdelays for data transfers.

Embodiments of the present invention generate an interrupt based on acontext configuration bit that is set after one or more contexts arecompleted without error. If the one or more contexts are completed withat least one error, the data transfer might be aborted. Once a contextis completed, the context is consumed. Embodiments of the presentinvention provide three processes for consuming contexts. The firstprocess generates a cache update interrupt for each data transfercontext that completes. The second process generates a cache updateinterrupt after a command that includes multiple data transfer contextscompletes. The third process generates a cache update interrupt after apredetermined number of contexts complete. In cases where multiple datatransfer contexts are completed before generating an interrupt, therange of LBAs for all completed data transfer contexts is maintained inbuffer memory.

As described, context cache 408 might retrieve a next context of acontext thread from context buffer 322 while a current context is beingprocessed. Context cache 408 compares the next context pointer with theend pointer corresponding to the end of the data transfer correspondingto the context thread. If the next context pointer is not equal to theend context pointer, the next context is read from context buffer 322.Embodiments of the present invention might include one or more copies ofthe next pointer and end pointer, such that the normal-priority contextthread can be interrupted to execute the high-priority context thread.High-priority threads might include contexts for operations such as SATAor SAS response frames, SAS TRANSFER READY frames, or otherhigh-priority data transfers.

CCM 410 is employed to process completed contexts, for example, bydeleting the context, generating an interrupt indicating the context hascompleted, or recycling the context pointer. FIG. 10 shows greaterdetail of CCM 410. CFPM 412 maintains a pool of unused context pointers(e.g., the buffer address where the context is stored). CFPM 412provides free context pointers when new contexts are created, and addspointers back to the free pointer pool when the context completes,without having to reorder contexts in the buffer memory. FIG. 11 showsgreater detail of CFPM 412.

As shown in FIG. 10, CCM 410 is coupled to instruction interface 314,RXDP 306 and TXDP 318, which provide pointers for completed contexts,shown as pointers 1004(0)-1004(N), to CCM 410. A context pointer is anindex of the buffer that corresponds to the buffer address where acontext is stored. The hardware registers in CCM 410 include bufferwrite FIFO 1008 and buffer read FIFO 1014. Buffer write FIFO 1008 storesenough pointers to provide one burst write operation to buffer subsystem205, shown as pointers 1010(0)-1010(N). In exemplary embodiments, bufferwrite FIFO 1008 stores 6 pointers in 3 datawords. Buffer read FIFO 1014stores the same number of pointers as buffer write FIFO 1008 to providea burst read operation to buffer subsystem 205. The entries in FIFOs1008 and 1014 might include error correcting code (ECC) protection, forexample, every 3 datawords of FIFO data might include 1 dataword of ECCdata, such that the overall burst operation size is 4 datawords (3data+1 ECC).

When a context pointer is provided to CCM 410, it is stored in one ofbuffer write FIFO 1008 and buffer read FIFO 1014. Together, the contentsof buffer write FIFO 1008, buffer read FIFO 1014 and CCQ buffer 1024form consumed context queue (CCQ) 1022, as indicated by the dashed line.As shown in FIG. 10, to provide variable queue depths, consumed contextqueue 1022 might be stored in buffer write FIFO 1008, buffer read FIFO1014, CCQ buffer 1024 in buffer subsystem 205, or a combination thereof.Context pointers are removed from CCQ 1022 in the order of contextcompletion. If buffer read FIFO 1014 is empty, context pointers aremoved to buffer read FIFO 1014 from one of CCQ buffer 1024 or bufferwrite FIFO 1008. CCQ buffer 1024 might be used to store context pointersreceived by buffer write FIFO 1008 when buffer read FIFO 1014 is full.To process a context pointer, CCM 410 loads the head entry of CCQ 1022to current pointer register 1018. CCM 410 reads the original copy of thecontext, shown as context 1026, from context buffer 322, and based onthe context data, might generate an interrupt, shown as 1028, to processthe context.

One or more of the context pointers in CCQ 1022 might be processedduring the same interrupt by employing flexible associations between thecontext interrupts and CCQ 1022. For example, by tracking LBAs forconsumed contexts, CCM 410 might process contexts for contiguous LBAs ina single interrupt. Alternatively, CCM 410 might process a predeterminednumber of one or more consumed contexts in a single interrupt bytracking a tag for each command. After the interrupt is processed, thecorresponding entry of CCQ 1022 is cleared and the next entry in CCQ1022 might be processed by generating a new interrupt corresponding tothe next entry. This process is repeated for subsequent consumedcontexts in CCQ 1022.

Completed contexts provided to CCM 410 might be consumed in one of fourways. First, a completed context might be cleared without recycling thecontext pointer to CFPM 412 and without generating an interrupt toperform any other processing. Second, a context pointer might be clearedwithout generating an interrupt, but is recycled to CFPM 412. Thesefirst two cases are generally controlled by multiplexer 1006, whichoptionally bypasses CFPM 412. Third, CCM 410 might generate an interruptand recycle the context pointer to CFPM 412. The context pointers areprovided to CCM 410, which loads the pointer into CCQ 1022. When thepointer is removed from CCQ 1022, CCM 412 loads the matching contextfrom context buffer 322 and generates an interrupt. While processing theinterrupt, the context is read and operations are performed, such astracking how often a given LBA is accessed. When the interrupt iscleared, CCM 410 sends the context pointer to CFPM 412 for recycling,and CCM 410 clears the context pointer from CCQ 1022. Fourth, CCM 410might generate an interrupt but not send the context pointer to CFPM 412for recycling.

FIG. 10 shows a typical embodiment of CCM 410 for a SATA application. ASAS embodiment of CCM 410 might employ the same structure as shown inFIG. 10, but include additional context sources to support duplicatemodules required in a two-port system (e.g., two instruction interfaces,two RXDPs and two TXDPs). Since each of the ports is running inparallel, both ports might be completing contexts in parallel.

FIG. 11 shows a block diagram of a context free pointer manager (CFPM)412. CFPM 412 maintains a pool of unused context pointers, shown as freecontext pool 1020, which might be stored in buffer subsystem 205. CFPM412 provides a context pointer when a new context is created, andrecycles context pointers after each context is completed. CFPM 412accepts pointers for completed contexts from CCM 410 and stores thepointers in buffer write FIFO 1102 and buffer read FIFO 1104, whichoperate in a similar manner as FIFOs 1008 and 1014, described above withregard to FIG. 10. Context pointers to be added to free context pool1020 are stored in buffer write FIFO 1102, and free context pointers tobe provided to other processing blocks (e.g., command parser 406 orcontext cache 408) are stored in buffer read FIFO 1104 until they can beprovided. As shown by multiplexer 1106, free context pool 1020 might bebypassed if Buffer Read FIFO 1104 is not full. This operates is a cacheof pointers and attempts to minimize buffer accesses. Buffer Read FIFO1104 stores 6 pointers so they are all available to use for contextgeneration. As pointers are recycled, they are stored in Buffer WriteFIFO 1102, and are moved to Buffer Read FIFO 1104 if there are openslots in Buffer Read FIFO 1104. This completely bypasses free contextpool 1020. The pointers are only written to free context pool 1020 whenboth Buffer Read FIFO 1104 and Buffer Write FIFO 1102 are full. Thepointers are only read from free context pool 1020 when both Buffer ReadFIFO 1104 and Buffer Write FIFO 1102 are empty. The context pointers areremoved one at a time as requested and pointer order is not maintained.CFPM 412 is substantially similar for both SATA and SAS applications.

Thus, as described herein, embodiments of the present invention providesupport for generating and executing dual threads of contexts. Forexample, embodiments of the present invention support a normal contextthread and a parallel, high priority context thread. This structuresupports generation of context threads by having a parallel structurefor generating contexts, and also supports execution of parallel contextthreads by having a parallel context fetch structure to supportinserting high priority contexts at an appropriate transfer boundary.Embodiments of the present invention provide the ability to generate ahigh priority context without changing a current context thread.

As described above with regard to FIGS. 2 and 3, embodiments of thepresent invention provide that a single data transfer at thecommunication link protocol level (e.g., link protocol core 304) mightbe split into one or more data transfer contexts for data transfersinternal to media controller 104. The data related to the one or morecontexts might be scattered in different locations in the data bufferand/or media, and need to be combined to form a single contiguous datatransfer at the protocol level. Thus, embodiments of the presentinvention allow a protocol command to be split into one or more contextsthat can later be recombined. Splitting a protocol command into contextsmight accommodate multiple buffer management techniques and multipleprotocol techniques, such as, for example, SATA programmed input/output(PIO) multiple and SAS multiple pending write commands. As will bedescribed, embodiments of the present invention decouple a data transferblock boundary from a protocol frame boundary. Thus, regardless the sizeof data frames transferred over communication link 102, internal datacontexts might be created to process the data transfer. The size of thedata contexts is not dependent on the protocol employed by communicationlink 102.

FIG. 12 shows a block diagram of exemplary protocol command contexts andthe associated data contexts for a write command in conformance with theSAS protocol. As shown in FIG. 12, a SAS write command might correspondto command context 1202 and one or more write contexts 1204(1)-1204(N)to provide scatter-gather buffer management support. For example, for aSAS write operation, SAS command context 1202 might correspond to theTRANSFER READY frame in accordance with the SAS protocol. The TRANSFERREADY frame generally enables write transfers from a source to mediacontroller 104. In embodiments of the present invention, multiple writetransfers might be active at a time. In response to the TRANSFER READYframe, command context 1202 is generated and generally corresponds tothe total amount of data that can be received for the write datacommand. For example, the command context might be sized appropriatelyfor meeting the link requirements such as maximum burst size while alsodividing write commands into appropriately sized pieces for internaltransfers. Additionally, the write command might be broken into one ormore TRANSFER READY amounts. Once the TRANSFER READY is sent, then theSAS target is committed to transferring (receiving) that amount of datafor that write command at that time.

As shown in FIG. 12, command context 1202 might correspond to one ormore write contexts 1204(1)-1204(N) that are generated to process thedata transfer. The size of write contexts 1204(1)-1204(N) mightcorrespond to chunk boundaries of data stored in media system 100, forexample, data stored in media 118, buffer 112 or buffer 114. The chunkboundaries are generally independent of the protocol frame boundariesand the overall size of the data transfer. A counter is employed totrack the number of chunk boundaries such that a new data transfercontext can be processed without affecting the other contexts. As shownin FIG. 12, command context 1202, corresponding to the SAS TRANSFERREADY frame, is linked to write contexts 1204(1)-1204(N) that are linkedtogether and provide pointer information for the buffer locationsstoring the data to be transferred. In exemplary embodiments of thepresent invention, write contexts 1204(1)-1204(N) might have the sameconfiguration options and match the overall data length provided incommand context 1202. One or more of write contexts 1204(1)-1204(N)might be stored in Pending Write Table (PWT) 324. As indicated by thedashed line, contexts 1204(1)-1204(N) might optionally be merged into asingle data transfer between communication link 102 and media 118, shownas data transfer 1210. This size of data transfer 1210 might be basedon, for example, a maximum burst size to media 118 or a number ofcontiguous chunks of the one or more write contexts.

In the SAS protocol, multiple write commands might be activesimultaneously, so write contexts might be suspended at frame boundarieson the protocol. To support multiple suspended contexts, PWT 324temporarily stores suspended contexts to decouple the suspended contextsfrom the protocol frame boundaries. Both frame boundaries and contextboundaries are maintained in PWT 324 so that write contexts are notnecessarily required to be aligned to protocol frame boundaries.

FIG. 13 shows a block diagram of exemplary protocol command contexts andthe associated data contexts for a read data transfer in conformancewith the SAS protocol. The SAS read data transfer shown in FIG. 13operates in a similar manner as the SAS write data transfer describedwith respect to FIG. 12. As shown in FIG. 13, command context 1302corresponds to the SAS read command and generally corresponds to thetotal data transfer size. As shown in FIG. 13, command context 1302might correspond to one or more read contexts 1306(1)-1306(N) that aregenerated to process the data transfer. As indicated by the dashed line,1312, base buffer pointer 1304 and the one or more read contexts1306(1)-1306(N) are optional, as will be described below. The size ofread contexts 1306(1)-1306(N) might correspond to chunk boundaries ofdata stored in media system 100, for example, data stored in media 118,buffer 112 or buffer 114. A context count for read contexts1306(1)-1306(N) might be maintained separately from a frame count so thecontext boundaries are independent of the frame boundaries.

As described above, the one or more read contexts 1306(1)-1306(N) areoptional, as embodiments of the present invention might, depending onthe size of the read data transfer or settings of media controller 104,employ varying context boundaries. For example, for small readoperations, only a single context per protocol command might be employed(e.g., only read command context 1302). In this case, a single contextis generated for the data transfer. Instruction interface 314 issues aninstruction for the data transfer length of the context and transmitdata path (TXDP) 318 transfers the data for that context. Alternatively,multiple data transfer contexts might be merged together to create alarger protocol instruction for better protocol efficiency, for exampleto send out data packets of a maximum packet size of communication link102. As shown in FIG. 13, read command context 1302 is used for theprotocol instruction length and is linked to one or more read contexts1306(1)-1306(N) that satisfy the overall instruction length. Readcontexts 1306(1)-1306(N) are processed by transmit data path 318 anddata is seamlessly transferred to link protocol core 304 until theinstruction length from read command context 1302 is met. Protocol frameboundaries are maintained independently of context boundaries, so framesof the maximum size allowed by the link protocol are sent until all ofread contexts 1306(1)-1306(N) have been processed. In general, onceprocessing of a read data context starts, the read data context remainsin the transmit data path 318 until completion.

In embodiments of the present invention, BAM 215 might generate readdata contexts without requiring a linked list of contexts in contextbuffer 322. As shown in FIG. 13, generated read command context 1302defines an entire data transfer length of the protocol instructionrequest, but this context references a list of context structuresaccessible by BAM 215, instead of contexts stored in buffer 322. Basepointer 1304 is employed to provide a single context in buffer 322 for atransfer, while the following contexts 1306(1)-1306(N) might begenerated by BAM 215. Base pointer 1304 might not be used when the oneor more read contexts 1306(1)-1306(N) are used or are not generated byBAM 215. BAM 215 might generate read contexts 1306(1)-1306(N) and,employing an internal context lookup algorithm, store data for each ofread contexts 1306(1)-1306(N) to Context Cache 408. The contexts areprovided from Context Cache 408 to TXDP 318, which provides the data tolink protocol core 304 to perform the read data transfer. Thus, BAM 215reduces the data structures that firmware running on processor 116generates and passes between routines, and provides for fasterprocessing of data contexts. This provides the ability to generatecontexts for a data transfer command in three ways, while stillsupporting the maximum transfer size: i) in a single context for thecommand and the data transfer in buffer 322 (e.g., context 1302); ii) acommand context (e.g., context 1302) with a single data transfer contextin buffer 322 (e.g., base pointer 1304) with multiple data transferentries in BAM 215 (e.g., contexts 1306(1)-1306(N)); and iii) one ormore contexts in buffer 322, split between a command context (e.g.,1302) and one or more data contexts (e.g. 1306(1)-1306(N)).

TXDP 318, based on the context configuration contained in commandcontext 1302, determines processing of a read context and what actionsare performed at context boundaries. For example, TXDP 318 tracks thecontext boundary using a context block count. If the current contextbeing processed by TXDP 318 indicates that there is another context inthe data transfer, TXDP 318 loads the next context when the currentcontext completes. Context Cache 408 might provide the next context,based on base pointer 1304, to TXDP 318 to continue the transfer withoutaffecting the protocol operation.

Embodiments of the present invention employing a host subsystemoperating in conformance with the SATA protocol might generally supportthe same features as described above with regard to FIGS. 12 and 13 forhost subsystems operating in conformance with the SAS protocol. Forexample, a subsystem operating in conformance with either protocol mightprovide contexts such that the overall protocol transfer context isseparate from one or more internal data transfer contexts.

In the SATA protocol, data packets are sent using one or more framesthat include a start-of-frame (SOF) delimiter, a data payload, a cyclicredundancy code (CRC) delimiter, and an end-of-frame (EOF) delimiter.The data payload contains user data organized according to a predefinedfile information structure (FIS). The FIS of the payload includes avalue representing a type parameter of the FIS. For example, afirst-party DMA (FPDMA) FIS generally requires the FIS indicate thetotal amount of data that media controller 104 can transfer in oneoperation. Typically, a SETUP FIS frame is sent, which is then followedby data transfer frames. The SETUP FIS must be processed before dataframes can be transmitted.

To support this protocol requirement, the execution of FIS setupoperations and the execution of data transfer operations are handledusing different independent contexts. For example, a data transfercontext can be split from the command context (e.g., the SATA setupcommand) while separately maintaining counts of protocol frames.Similarly as described above with regard to FIGS. 12 and 13, embodimentsof the present invention operating in conformance with the SATA protocolmight process a setup command and a data transfer using one context, ormight split the command and data transfer into one or more contexts toprovide scatter-gather buffer management support. Other embodiments ofthe present invention might process a command and data transfer as acommand context having a single data transfer context in the buffer withmultiple data transfer entries in BAM 215.

As shown in FIG. 14, embodiments of the present invention generate anumber of contexts 1402(1)-1402(N) that correspond to storage of data isin buffer subsystem 205. For substantially every discontinuity of datain the buffer, a new context is required to point to that data. Each ofcontexts 1402(1)-1402(N) transfers the SETUP FIS and also transfers thedata corresponding to each FIS, limiting the amount of data that can betransmitted for each SETUP FIS.

As shown in FIG. 15, embodiments of the present invention generate asetup context 1502 and a number of contexts 1504(1)-1504(N) thatcorrespond to how data is stored in buffer subsystem 205. Each of datacontexts 1504(1)-1504(N) correspond to a single SETUP FIS context 1502.As indicated by the dashed line, data contexts 1504(1)-1504(N) might becombined into a single data transfer 1510. In FIG. 15, data contexts1504(1)-1504(N) generally transmit more data than setup/data contexts1402(1)-1402(N) of FIG. 14 because each context 1504(1)-1504(N) does notneed to include a SETUP FIS. In this case, Instruction Interface 314sends a SETUP FIS for the entire transfer, and data contexts1504(1)-1504(N) are merged together (e.g., by TXDP 318 or RXDP 306),providing a single data transfer.

Embodiments such as shown in FIG. 15 might beneficially be employed, forexample, to process SATA programmed input/output (PIO) Multiplecommands. PIO Multiple commands include data transfers for one or morememory addresses, where the data in the PIO Multiple command is notnecessarily aligned with a buffer management boundary. Thus, embodimentsof the present invention split PIO Multiple commands into one or morecontexts that align to chunk boundaries of data stored in media system100 (e.g., data stored in media 118, buffer 112 or buffer 114). Chunkboundaries might generally be independent of the protocol frameboundaries and the overall size of the transfer, although chunk,protocol frame, context, and media boundaries all align to the end ofthe last transfer.

As shown in FIG. 16, embodiments of the present invention generate oneor more data contexts independently of context buffer 322. Similarly asshown in FIG. 15, one context is generated for the SETUP FIS (setupcontext 1602). A second context, base pointer 1604, is generated andstored in context buffer 322 to provide a reference pointer to aseparate data transfer list in BAM 215. BAM 215 generates individualdata transfer contexts 1606(1)-1606(N) and, during the data transfer,writes each of them to Context Cache 408 in sequence. Individual datatransfer contexts 1606(1)-1606(N) are moved from Context Cache 408 tothe data paths (e.g., TXDP 318) to perform the data transfers. Thesedata transfer contexts are not stored in context buffer 322 and onlyexist in Context Cache 408 and the corresponding data path. The datapath merges data contexts 1606(1)-1606(N) into a single data transfer.When BAM 215 generates the final data transfer context (e.g., 1606(M),base pointer 1602 is cleared from Context Cache 408 and Context Cache408 processes the next context its queue. Embodiments of the presentinvention might employ a single context combining the SETUP FIS contextwith the base pointer, similarly as shown in FIG. 14, except BAM 215generates data contexts 1606(1)-1606(N).

Embodiments of the present invention might employ independent receiveand transmit direct memory access (DMA) modules in addition to contextcache 408, pending write table (PWT) 324, and buffer allocation manager(BAM) 215. Independent RXDMA and TXDMA modules might allow for fullduplex operations. Further, independent RXDMA and TXDMA modules,combined with context staging in context cache 408, provide a contextexecution pipeline that provides the advantages of i) allowingmodifications to a context before it is executed by the correspondingDMA, ii) staging a next context in a context cache to improveperformance and allow modification of the context before it is executedby the corresponding DMA, and iii) staging contexts to accommodate dataencryption.

FIG. 17 shows an embodiment of RXDP 306 employed in a single port SATAapplication (i.e. a consumer application). As shown, RXDP 306 includesreceive direct memory access module (RXDMA) 1702. In general, for a SATAapplication, since the SATA protocol does not allow multiple activewrite commands, only one write context is active at a time, and theactive context must be completed before beginning another data transfer.However, RXDMA 1702 might employ two write contexts: a first writecontext, a receive data context (RX write context 1704), to performreceive-side context operations (e.g., between RXDMA 1702 and RX Buffer308) and a second write context, a buffer context (B-C write context1706), to perform buffer-side context operations (e.g., interface RXDMA1702, buffer FIFO 1712 and buffer subsystem 205). This allows thereceive-side operations and the buffer-side operations to be performedindependently of each other. This operational independence supportsoperation of encryption datapath 316, since, for example, encryptiondatapath 316 might introduce delay in processing received data.Embodiments of the present invention might beneficially employ a singleentry PWT 324 to stage a context for the receive-side context (1704)operation while the buffer-side context (1706) operation is completed.This provides common handling contexts for SATA and SAS applications tosupport a modular design. RX Frame Status 1708 is described in greaterdetail in regard to FIG. 26.

FIG. 18 shows a flow diagram of context process 1800 for a SAS writedata transfer, as might be employed by host subsystem 201 of FIG. 2. Atstep 1802, a write data transfer is initiated by a host initiatorcoupled to communication link 102. At step 1804, a write context isgenerated. As described herein, the write context might be stored in abuffer, for example a context buffer 322 of buffer subsystem 205. Atstep 1806, Context Cache 408 retrieves the write context from contextbuffer 322 of buffer subsystem 205. At step 1808, the write context isprovided to Instruction Interface 314. Instruction Interface 314provides TRANSFER READY and PWT ID to RXDMA 1702 so it can check theincoming data and the TRANSFER READY amount as the data is laterreceived. Instruction Interface 314 then discards the TRANSFER READYcontext since RXDMA 1702 and PWT 324 contain that information.

At step 1812, Instruction Interface 314 requests that link protocol core304 send a TRANSFER READY frame to the host initiator. The TRANSFERREADY frame includes a write transfer tag indicating a correspondingcontext entry in pending write table (PWT) 324. At step 1814,Instruction Interface 314 sends the PWT ID to PWT 324, and, at step1816, PWT 324 adds the write context to a context list at locationcorresponding to transfer tag. PWT 324 might retrieve the write context,based on the PWT ID, from context cache 408, or a cache internal to PWT324. At step 1818, link protocol core 304 receives the data frame sentby the host initiator, and the data frame is stored in RX Buffer 308. Atstep 1820, RXDP 306, via RXDMA 1702, retrieves the write context fromPWT 324 based on the write tag, which is provided in the header of thedata frame stored in RX Buffer 308. PWT 324 swaps contexts by i) storingcurrent context from RXDMA 1702 and ii) providing requested contextsfrom PWT 324. At step 1822, RXDP 306, via RXDMA 1702, transfers thereceived data frame from RX Buffer 308 to buffer subsystem 205. At step1823, if the last frame of the data transfer was processed, then thedata transfer is complete at step 1824. Otherwise, additional frames areleft to process, and the process returns to step 1814 to processadditional data frames to satisfy the entire data transfer, for example,by PWT 324 retrieving a next write context from the context cache.

Context process 1800 of FIG. 18 corresponds to a SAS write datatransfer, but might be slightly different for SATA transfers. In SATA,instead of TRANSFER READY, there is a DMA Setup (Write), and only asingle write is active at any one time. Thus, for SATA, InstructionInterface 314 tracks the total transfer length and RXDP 306 indicates toInstruction Interface 314 whenever it receives a frame.

Embodiments of the present invention might provide that multiplecontexts are combined into a single TRANSFER READY frame. When multiplecontexts are combined into one TRANSFER READY frame, PWT 324 isconfigured to process a thread of contexts that are coalesced togetheras data for each context is received. Instruction Interface 314 isconfigured to generate the TRANSFER READY frame to include a transfercount of all the contexts in the thread for that portion of the writecommand. The contexts are linked together and desirably have the sameconfiguration such that only the transfer length and buffer pointerlocations change between contexts in the thread. The linked contextsmight be generated by Buffer Allocation Manager (BAM) 215. For example,the thread of contexts might correspond to single context havingmultiple entries in BAM 215, or multiple individual contexts in thebuffer that are joined together to advantageously utilize the maximumframe transfer size.

FIG. 19 shows an exemplary embodiment of TX datapath (TXDP) 318 thatmight be employed in a single port SATA application (i.e. a consumerapplication). TXDP 318 is employed in a system for a consumerapplication operating in accordance with the SATA protocol. As shown,TXDP 318 includes transmit direct memory access module (TXDMA) 1902.TXDP 318 handles outgoing data from buffer subsystem 205 to linkprotocol core 302 in response to, for example, a host read request. TXDP318 includes TX buffer 320 that operates to synchronize data between theinternal data path and the link protocol. In order to maintain the flowof data across multiple contexts without idle time on the protocol, TXDP318 pre-fetches data into TX Buffer 320 via TXDMA 1902, as Link ProtocolCore 304 is providing data for a previous context to communication link102, assuring that data is available in TX Buffer 320 when link protocolcore 304 is ready for data corresponding to the next context.

Similarly as described in regard to write contexts 1704 and 1706 of FIG.17, TXDMA 1902 might employ two read contexts: a first read context, B-Cread context 1904, to perform buffer-side context operations (e.g.,between TXDMA 1902, buffer FIFO 1908 and buffer subsystem 205) and asecond read context, TX read context 1906, to perform transmit-sidecontext operations (e.g., between TXDMA 1902 and TX Buffer 320). Thesetwo read contexts allow the transmit-side operations and the buffer-sideoperations to be performed independently of each other, which supportsoperation of encryption datapath 316, since, for example, encryptiondatapath 316 might introduce delay in processing received data.

TXDMA 1906 moves data from buffer subsystem 205 to TX Buffer 320 to beprovided to Link Protocol Core 304. Data is provided from buffersubsystem 205 in one or more chunks of data, for example, in a chunksize employed by media 118. TX Buffer 320 reformats the one or more datachunks into continuous data for transmission according to the protocolemployed by communication link 102 (e.g., frames, packets, etc.). TXBuffer 320 might supply data to link protocol core 304 to reformat oneor more data chunks into a frame of the maximum size allowed by theprotocol employed by communication link 102. TX Buffer 320 might alsoadd parity data or other error correction data to the data fortransmission. Link Protocol Core 304 retrieves the data for transmissionfrom TX Buffer 320, and provides data frames to communication link 102.

Data transfers might be paused for a protocol disconnect or error, andthe context associated with the data transfer remains in TXDP 318 untilthe data transfer can be completed. The context might block linkprotocol core 304 until it is processed. Some frames might be manuallyformatted in TX Buffer 320, while other frames might automatically begenerated in TX Buffer 320.

FIG. 20 shows a flow diagram of context process 2000 for a read datatransfer, as might be employed by host subsystem 201 of FIG. 2. At step2002, a read data transfer is initiated by a host initiator coupled tocommunication link 102. At step 2004, processor 116 checks whether therequested data of the read operation is already stored in buffersubsystem 205 (e.g., a cache hit). If the requested data is stored inbuffer subsystem 205, at step 2006, no access of media 118 is required,and, at step 2010, the requested data is read directly from the bufferto context cache 408. Otherwise, at step 2006 if the requested data isnot stored in buffer subsystem 205, one or more media contexts aregenerated at step 2008 to read the requested data from media 118 tobuffer subsystem 205. At step 2010, context cache 408 retrieves therequested data from the buffer.

At step 2010, a read context is provided to TXDMA 1902 to retrieve thecorresponding data from buffer subsystem 205. At step 2014, the data istransferred to TX Buffer 2014, where the data is grouped into chunkscorresponding to the protocol frame size at step 2016. At step 2018,instruction interface 314 requests that link protocol core 304 send oneor more data frames to fulfill the read request. At step 2020, data istransferred from TX Buffer 320 to link protocol core 304 fortransmission over communication link 102.

At step 2022, if TX Buffer 320 is loaded with the data to satisfy thecurrent context so that context is complete. The completed context isdiscarded, and data for a next context of the transfer is loaded intoTXDMA 1902 as the data corresponding to a previous context of thetransfer is provided to link protocol core 304 at step 2020 so datacorresponding to the next context is ready to be provided to linkprotocol core 304 when the previous context is complete, thus reducingidle time of link protocol core 304. As soon as all the data for acontext is loaded into TX Buffer 320, the context is cleared from TXDMA1902 so data for the next context can be fetched from buffer subsystem205. There are independent host-side TXDMA and media-side buffer-client(B-C) contexts for read data transfers, such as were employed in the RXdatapaths for write data transfers as described with regard to FIGS. 17and 18.

At step 2024, link protocol core 304 sends the data frame overcommunication link 102. At step 2026, if additional data frames remainto be sent for the read request, processing returns to step 2020 totransfer data from buffer 320 to link protocol core 304. Otherwise, ifthe last data frame has been sent, the read transfer is complete at step2028.

FIG. 21 shows a block diagram of a host subsystem for a two-port system,such as for SAS devices, having dual link protocol cores, dual RXDPs anddual TXDPs to support 2-port communication. The embodiment shown in FIG.21 operates similarly as described with regard herein to single-portdevices, although, as shown in FIG. 3, a single port applicationgenerally might not include modules to support two ports. Thus,embodiments of the present invention provide that pieces of a SAS hostsubsystem (e.g., FIG. 21) might be scaled back to provide a SATA hostsubsystem (e.g., FIG. 3). As shown in FIG. 21, for a two-port SASdevice, dual RXDPs 306 and 2106, dual TXDPs 318 and 2118, dualinstruction interfaces 314 and 2114, dual context caches 408 and 2108and dual link protocol cores 304 and 2104 are employed to support dualport operation.

Thus, as shown in FIG. 21, a two port SAS device might include a firstcontext cache module, 408, to interface to TXDP 318 and instructioninterface 314 for port A, which has corresponding link protocol core304. A second context cache module, 2108, interfaces to TXDP 2118 andinstruction interface 2114 for port B, which has corresponding linkprotocol core 2104. Each context cache module 408 and 2108 alsointerfaces with PWT 324, buffer subsystem 205, and BAM 215, which areshared between port A and port B. Each context cache module 408 and 2108retrieves the next context to be executed from the thread of contexts asdescribed previously with respect to FIG. 4. Pending Write Table 324,Tag Manager 402, ILT 404 and Command Parser 406 might be scaled tosupport dual-port operation, but operate generally such as described inregard to FIGS. 3-6. The RXDP and TXDP modules might be substantiallyunchanged between single port SATA applications and dual port SASapplications.

FIG. 22 shows an embodiment of RXDP 306 and 2106 employed in a dual-portSAS application such as shown in FIG. 21. As shown in FIG. 22, severalfeatures are included to support the SAS protocol, such as initiatorlookup table 404 to support multiple initiators, dual link protocolcores, 304 and 2104, to support dual-port full-duplex communication,dual RX datapaths 306 and 2106, and dual RXDMA modules 1702 and 2202 toprovide higher bandwidth. In exemplary embodiments of the presentinvention, one DMA module might be dedicated to a specific port of thecommunication link. As shown in FIG. 22, RXDMA module 1702 is dedicatedto link protocol core 304 for port A, and RXDMA module 2202 is dedicatedto link protocol core 2104 for port B. FIG. 22 shows only additionaldetail of RXDMA module 2202, although typically both RXDMA modules 1702and 2202 might be substantially similar. To support two full ratesimultaneous DMA data transfers, pending write table 324 might have anindependent interface with each RXDMA module 1702 and 2202, shown asindependent interfaces labeled DMA A and DMA B, respectively. Pendingwrite table 324 also supports processing of multiple outstanding writecontexts. In an exemplary embodiment of the present invention, eightactive write contexts are preferably supported. Received command framesare checked and routed to internal hardware or a command buffer. Forexample, if no other commands are queued, the command is sent to commandparser 406. If other commands are queued, the command is sent to abuffer and added to the queue. Queued commands might be maintained in aFIFO queue (e.g., command FIFO 323 of buffer subsystem 205) and areprocessed in the order received. RXDP 306 writes commands to commandFIFO 323 when there is more than one command outstanding and commandsmust be queued. New commands are written to the tail of command FIFO323. Command parser 406 reads commands from the head of command FIFO323, preserving the order of the commands. RX Frame Status 1708 and RXFrame Status 2209 will be described in greater detail in regard to FIG.26.

As described herein, embodiments of the present invention might providea write context split between the RXDMA module and the buffer interfaceto handle encryption pipeline operation. A split in contexts might beimplemented because the size of incoming data frames to RXDPs 306 and2106 is not necessarily the same size as the size of outgoing datablocks. As shown, RXDPs 306 and 2106 might interface with EncryptionData Path 316. Encryption Data Path 316 provides data encryption anddecryption as a pipeline stage in the data path. Encryption Data Path316 might encrypt or decrypt one or more blocks of data beingtransferred between buffer subsystem 205 and at least one of the linkprotocol cores 304 and 2104. RXDP 306 might add any CRC (cyclicredundancy check) or other ECC (error correction code) protection todata blocks. As shown in FIG. 22, the write context might be split andprovided to pending write table 324 as RX Write Context 2236 and abuffer-client (B-C) write context 2240. This context split providesindependent operation of RXDMA 2202 to receive data from RX buffer 308and buffer-client DMA 2238 to provide data to buffer FIFO 1712. Thisindependent operation allows for delay variations caused by theoperation of Encryption Datapath 316. For example, Encryption Datapath316 might have nondeterministic delay since data frame boundaries arenot necessarily aligned with encryption block boundaries.

Since the SAS protocol allows for multiple active write commands, PWT324 provides RXDMA modules 1702 and 2202 access to a list of activewrite commands. The active write commands might be loaded relativelyquickly into the respective RXDMA module to store the write datatransfer of received data frames. Since the received frames do notnecessarily align with host block boundaries or encryption blockboundaries, extra information might be maintained for each outstandingwrite command, such as, for example, an intermediate CRC, anintermediate data integrity field (DIF), block ECC, or an intermediateblock count. PWT 324 might be implemented as RAM or as a register filethat stores context information for each write transfer entry along withthe associated intermediate information for each entry. The storage sizeof PWT 324 might be determined such that the data transfer rate ismaintained in RXDP 306 while entries are being loaded to one of RXDMAmodule 1702 or 2202 from PWT 324. In embodiments of the presentinvention, the data rate of RXDMA modules 1702 and 2202 might be fasterthan the data rate of the link protocol, such that RXDMA modules 1702and 2202 can process a currently received data frame and flush RXbuffers 308 and 2208 without throttling the link protocol. PWT 324 willbe described in greater detail with regard to FIG. 24.

FIG. 23 shows an embodiment of TXDP 318 and 2318 employed in a dual-portSAS application such as shown in FIG. 21. As shown in FIG. 23, severalfeatures are included to support the SAS protocol, such as dual linkprotocol cores, 304 and 2104, to support dual-port full-duplexcommunication, dual TX datapaths 3318 and 2318, and dual TXDMA modules1902 and 2302 to provide higher bandwidth. In exemplary embodiments ofthe present invention, one DMA module might be dedicated to a specificport of the communication link. As shown in FIG. 23, TXDMA module 1902is dedicated to link protocol core 304 for port A, and TXDMA module 2302is dedicated to link protocol core 2104 for port B. FIG. 23 shows onlyadditional detail of TXDMA module 2302, although typically both TXDMAmodules 1902 and 2302 might be substantially similar. Queued commandsmight be maintained in a FIFO queue (e.g., context buffer 322 of buffersubsystem 205) and are processed in the order received.

As described herein, embodiments of the present invention might providea read context split between the TXDMA module and the buffer interfaceto handle encryption pipeline operation. A split in contexts might beimplemented because the size of data chunks stored on media 118 andbuffer subsystem 205 might not be the same as the size of outgoing dataframes from TXDPs 318 and 2318 to link protocol cores 304 and 2104,respectively. As shown, TXDPs 318 and 2318 might interface withEncryption Data Path 316. Encryption Data Path 316 provides dataencryption and decryption as a pipeline stage in the data path.Encryption Data Path 316 might encrypt or decrypt one or more blocks ofdata being transferred between buffer subsystem 205 and at least one ofthe link protocol cores 304 and 2104. As describe with regard to the RXdatapaths shown in FIG. 22, this independent operation allows for delayvariations caused by the operation of Encryption Datapath 316. Forexample, Encryption Datapath 316 might have nondeterministic delay sincedata frame boundaries are not necessarily aligned with encryption blockboundaries.

Embodiments of the present invention provide for processing multiplewrite data contexts. Write data contexts might be processed in parallelwith other context processing, supporting multiple simultaneousoutstanding write commands in parallel with other context operations. Byemploying a write data context thread that is independent from othercontext threads, the write data context thread does not impact theexecution of the other context threads, allowing high-performancefull-duplex operation.

FIG. 24 shows a block diagram of an exemplary embodiment of PendingWrite Table (PWT) 324. As shown, PWT 324 includes PWT context cache2414, PWT context control 2412, PWT storage 2404, context completionmodule 2402, receive (RX) context control 2416 and buffer-client (B-C)context control 2418. PWT storage 2404 includes RX context entries 2406,B-C context entries 2408, and DMA context entries 2410. Write contextprocessing is independent of buffer context processing, as shown by PWTContext Cache 2414 and DMA context entries 2410 in PWT storage 2404. DMAcontext entries 2410 provide a single entry pipeline stage for RX writecontexts and B-C write contexts. One DMA context entry is kept availableand ready to use before the active RX context or B-C context iscompleted. When the active context is completed, the staged entry in thecorresponding one of RX context entries 2406 and B-C context entries2408 is loaded as the active context in PWT 324 by one of controlmodules 2416 and 2418, and the corresponding entry in DMA contextentries 2410 is discarded. If there are additional contexts in the writedata context thread PWT Context Cache 2414 loads the next context frombuffer subsystem 205 so the next PWT Context is available before theactive entry completes.

There is a staged context for each PWT Entry (e.g., RX context entries2406 and B-C context entries 2408), but PWT Context Cache 2414 is sharedfor all PWT entries. PWT Context Cache 2414 is first-come, first-servedcontext cache in the case of multiple simultaneous requests. Contextsstored in PWT Context Cache 2414 might be modified by processor 116before the context is loaded to PWT DMA Context entries 2410. Thus,contexts might be modified outside of the performance path of activecontexts.

PWT Context Cache 2414 fetches write data contexts from buffer subsystem205. PWT Context Cache 2414 is independent of the regular context cache408 for host data requests. PWT Context Cache 2414 allows mediacontroller 104 to quickly switch between different Pending Write Entriesto handle the different received frame boundaries since a SAS Initiatorcan send data frames for a TRANSFER READY request at its convenience.Since there can be an entire thread of contexts associated with eachPending Write Entry, PWT 324 needs to react to incoming data trafficwithout impacting the context thread currently being processed. A stagedcontext entry allows shared context cache 2414 to stay ahead of theactive Pending entry.

As shown in FIG. 24, for a SAS device, one PWT (324) is shared by boththe Port A and Port B Receive Datapaths, 306 and 2106, respectively. InFIG. 24, only the details of RXDMA module 2202 are shown, but RXDMAmodule 1702 might generally be substantially the same. As indicated bythe dashed line, control signals are passed between each of RXDMA 1702and 2202 and RX context control 2416 and B-C context control 2416. Inembodiments of the present invention, PWT 324 stores information for upto eight contexts. These contexts are employed to move write data tobuffer subsystem 205 after transmitting TRANSFER READY frames. Thus, B-Ccontext entries 2408 supports eight B-C contexts, RX context entries2406 supports eight RX contexts, and DMA context entries 2410 supportseight DMA contexts to feed the B-C and RX contexts. DMA context entries2410 might load contexts from up to eight context threads. As shown,context completion module 2402 handles context completion tasks such asrequesting that an instruction interface (e.g., 314 or 2114) transmit aresponse, delete the command tag from tag manager 402 (not shown in FIG.24), and recycle the context pointer in CCM 410 and CFPM 412.

When a series of contexts is created to transmit a TRANSFER READY frameand receive the corresponding data from the initiator, an entry in PWT324 is allocated. When a data frame is provided at the output of thereceive buffer (e.g., 308 or 2208), the RXDP (e.g., 306 or 2106) loadsthe corresponding context from RX context entries 2406. The data framemight then be removed from the receive buffer. The data received by theRX buffers is possibly interleaved with one or more separate commands.In same context mode, the entire data transfer is represented by asingle context. If a data frame for a different command is received nextby the RX buffer, then RXDP 306 writes the RX context for the previousframe to RX context control 2416 and loads the corresponding RX contextfor the current data frame. Once all data for a context has been movedto buffer subsystem 205 and a status frame has optionally been sent,then the entry of PWT 324 is completed and can be allocated for a newtransfer.

In different context mode, one TRANSFER READY context is created for theinstruction interface (e.g. 314 or 2114) to send the TRANSFER READYframe. A series of DMA contexts are created to process the TRANSFERREADY context. The series of DMA contexts must be available to PWT 324as the matching data is received at the RX buffer. A separate thread ofDMA contexts is created for each TRANSFER READY context. RX and B-Ccontext entries 2406 and 2408 provide the current contexts to RX contextmodule 2236 and B-C context module 2240. PWT storage module 2404 alsofetches and stores the next DMA context in the write thread. By havingthe next context available, PWT 324 and RX datapaths 306 and 2106 canquickly change context threads when data for a different command isreceived. As each DMA context is consumed, PWT Context cache 2414fetches the next context from, for example, buffer subsystem 205.

Embodiments of the present invention provide generic DMA operation inmedia controller 104. This generic DMA capability might allow mediacontroller 104 to copy data from one buffer location to another and tochange the format of data as it is moved. Embodiments of the presentinvention might provide a connection between the independent receive andtransmit DMA modules (e.g., RXDMA modules 1702 and 2202 and TXDMAmodules 1902, 2302), allowing isolation of internal data transfers fromlink protocol cores (e.g., 304 and 2104) without a dedicated DMA modulefor internal data management. Thus, embodiments of the present inventionprovide internal loopback capability using the RX and TXDMA modules.Embodiments of the present invention might support features employingthe internal Generic DMA such as, for example, internal transfers ofdata in buffer memory, memory test pattern generation and checking, datacopy with encryption, and repetitive write operations to media 118.

FIG. 25 shows Generic DMA (GDMA) module 2502 integrated with RXDP 306and TXDP 318. As shown, GDMA module 2502 is placed between TX Buffer 320and RX Buffer 308 so it is isolated from the circuitry of RXDP 306 andTXDP 318. TX Buffer 320 is employed as a FIFO buffer, and its DataAvailable index is provided to GDMA 2502. RX Buffer 308 writes data insegments with a status entry corresponding to each data segment. Thesestatus entries are generated by status generator 2506 and are used tosynchronize data segments between the link protocol and the mediaprotocol. GDMA 2502 formats status entries substantially the same asregular data packets received from Link Protocol Core 304. Thus, RXDP306 operates without any changes to its structure. To enable GDMA 2502,Link Protocol Core 304 is placed into an idle mode where it does notrespond to incoming data transfer requests for the duration of the GDMAoperation. When the GDMA operation has been completed, Link ProtocolCore 304 is returned to normal operation mode.

Embodiments of the present invention might employ GDMA module 2502 toperform data operations where link protocol core 304 is beneficiallyisolated from the data path. Such operations might include: 1) movebuffer data from one buffer location to another in buffer subsystem 205;2) move host data from one buffer location to another; 3) read andoverwrite host data from one or more buffer locations; 4) read encryptedbuffer cipher text data, decrypt the buffer data, and then write plaintext data; 5) read buffer plain text data, encrypt the buffer data, andthen write cipher text data; and 6) performing memory tests.

GDMA 2502 might support at least four transfer modes: i) loopback mode,ii) write same mode, iii) memory test mode, and iv) memory read testmode. In loopback mode, GDMA 2502 is programmed with a Total TransferCount indicating the size of the data transfer and configurationinformation indicating the type of the data transfer. GDMA 2502 thenchecks to determine if data can be stored in TX Buffer 320 and if datacan be moved from TX Buffer 320 to RX Buffer 308. GDMA 2502 then movesthe data from TX Buffer 320 to RX Buffer 308 and status generator 2506creates a status entry after data has been written to RX Buffer 308.GDMA 2502 can be throttled by TX Buffer 320, but will continue the datatransfer until the Total Transfer Count reaches zero.

In write same mode, GDMA 2502 is also programmed with the Total TransferCount and configuration information. TX Buffer 320 is loaded with asingle block of data that is to be written to multiple locations inmedia 118. TX Buffer 320 includes a wrap pointer that is adjusted towrap at the block data boundary. In write same mode, GDMA 2502 does notcheck to determine if data can be stored in TX Buffer 320 since only oneblock is stored as TX Buffer 320 repeats the same data blockcontinuously until the Total Transfer Count reaches zero. TXDP 318 isgenerally not involved in a write same operation because the data blockis already stored in TX Buffer 320. GDMA 2502 routes the data through RXBuffer 308 and RXDP 306.

In memory write test mode, GDMA 2502 is programmed with total transfercount, configuration information, and a data pattern configuration.Memory test module 2504 generates a data pattern as defined by one ormore data pattern configuration options set by a user. This data patternis written to RX Buffer 308 and routed through RXDP 306 until the TotalTransfer Count reaches zero. TX Buffer 320 and TXDP 318 are not involvedin a memory write test operation. The data pattern is stored to media118 and optionally checked or validated using memory read test mode.

Memory test data patterns are defined by writing the data patternconfiguration options to a register in GDMA 2502. The test pattern isgenerated according to four data pattern configuration options: i) aRotate Left option shifts the pattern left by a single bit for eachdataword transferred, ii) a Rotate Right option shifts the pattern rightby a single bit for each dataword transferred, iii) an Add option adds apredetermined value to the pattern for each dataword transferred, andiv) an Add byte-wise option performs byte-wise addition of apredetermined value and the pattern for each dataword transferred. Thus,embodiments of the present invention support walking zeros testpatterns, walking ones test patterns, and incrementing test patterns.

In memory read test mode, GDMA 2502 is programmed with Total TransferCount, configuration information, and the data pattern configuration.TXDP 318 is programmed to route data through TX Buffer 320 to GDMA 2502.GDMA 2502 then compares the incoming data from TX Buffer 320 with thedata pattern configuration. Each dataword is compared and discardeduntil the Total Transfer Count reaches zero or a difference betweenreceived data and the test pattern is detected by memory test module2504. RX Buffer 308 and RXDP 306 are not used for memory read testoperations.

GDMA 2502 operates with the same clock as Link Protocol Core 304 andconverts the output of TX Buffer 320 into frame structures that arewritten to RX Buffer 308. During GDMA operations, RXDP 306 is configuredto bypass ILT 404 and Tag Manager 402. Data is sent directly from TXBuffer 320 to RX Buffer 308, and RX Buffer 308 creates a frame formatcompatible with RXDP 306. RXDP 306 is configured to bypass the headerand frame checks, as described below, since the header and status fieldsof each test frame contain dummy data for the memory test modes.

Embodiments of the present invention pass status information along witheach frame as it is synchronized between the link protocol and mediacontroller 104. This frame status information allows media controller104 to perform checks on data and command frames before the frame isremoved from the RX Buffer (e.g., at least one of RX Buffers 308 and2208, simplifying handling of command and other frame errors.Embodiments of the present invention provide parallel frame checking andframe data buffering. Status information is extracted from the receivedframe before the frame is removed from the RX Buffer, thus, avoidingproblems in handling exceptions that might occur with received framesthat are moved further along the receive datapath, which might result in“partially moved” frames.

FIG. 26 shows a block diagram of RXDP 306, which is adapted to provideframe and command validation for received frames. As shown, RXDP 306includes RX Buffer 308 that generally passes frames from Link ProtocolCore 304 to RXDMA 1702. The frames might contain data, commands, orother information. Exception conditions are beneficially detected beforeany of the frame is removed from RX Buffer 308 so the frame is static inRX Buffer 308 when the exception is detected. Generally, RXDP 306automatically handles data and command frames and generates an interruptfor all other frame types (i.e. exceptions). For all frames, RXDP 306checks if there were any link errors that occurred during the receptionof the frame. For data frames, RXDP 306 checks Initiator and Connectioninformation to determine if the data frame was routed properly and wasreceived at the proper time. For command frames, RXDP 306 checks theinitiator info, connection info, and command tag to verify the commandbefore moving the command from RX Buffer 308.

To allow the frame checks to occur before the frame is removed from RXBuffer 308, the data payload portion of the frame is separated from thestatus information for that frame, shown as RX data 2608 and RX status2610. As shown, RX frame status module 1708 receives RX status 2610. RXstatus 2610 indicates that a frame is received and is available to RXDP306 before the frame is removed from RX Buffer 308. RXDP 306 reads allof the status information for that frame. Since some of the statusinformation required to perform the frame checks (e.g. the Command Tag,Initiator Information) are contained in the frame or in other modules ofmedia controller 104, status parser and extractor 2602 extracts thestatus data from the frame and modules of media controller 104 as theframe data is written to RX Buffer 308. Extracted status data is storedin RX status data module 2604. For SAS, since multiple initiators andconnections are possible, the RX status information includes i) framestatus (e.g. data, command, header, payload, or other frame type), ii)frame link error information, iii) initiator information, iv) connectioninformation, and v) the command tag. For SATA, since there is only asingle initiator, the initiator and connection information is generallynot required.

RX status data module 2604 might generally include one or more registersfor storing RX status data. For example, some embodiments might include32-bit RX Buffer Status registers. When the frame status indicates thatthe received frame is a header frame, the RX status data might includethe initiator connection tag (ICT), a link protocol code, an initiatorport number, and a starting address of the received frame in RX Buffer308. When the frame status indicates that the received frame is apayload frame, the RX status data might include the frame length andflags that are set to indicate frame errors such as, for example, CRC,alignment, parity, overflow, and other errors. Other flags mightindicate that additional frames are included in the corresponding datatransfer operation.

RX status validation module 2606 might include one or more registers fortransferring RX status data to other modules of media controller 104such as, for example, RXDMA module 1702, tag manager 402, command parser406, PWT 324, and ILT 404. For example, for a received SAS frame, datamight be extracted from the received frame that indicates the framelength of the command, the protocol transfer rate (which is saved withthe command and stored in the corresponding context), the Pending WriteTable ID associated with the data transfer, the Initiator Connection Tag(ICT), the command tag for a data frame, and the WWN of the initiator.For example, RX status validation module 2606 might pass the WWN and ICTto ILT 404 to verify if the received frame was from a known, active,initiator.

Embodiments of the present invention employing an RX datapath asdescribed herein provide the benefit of verifying a received framebefore the frame is removed from the RX Buffer, which allows for commonhandling of any frame exceptions.

Both the SATA and SAS protocols include certain commands that aredefined as high priority commands that should be processed as fast aspossible. Since high priority commands might be mixed with other normalcommands, an early indication that a high priority command was received,without reordering other commands, embodiments of the present inventionprovide an early indication that a high priority command was received,which allows multiple high priority commands to be processed as part ofthe normal command processing sequence. As will be described herein,embodiments of the present invention employ outstanding command FIFO 323that might be configured to detect and count high priority commands asthey are added to the tail end of the FIFO. Upon detecting a highpriority command, an interrupt might be generated to process the highpriority command.

The SATA protocol includes several QUEUED commands that might be handledas high priority commands. For example, the NCQ QUEUE MANAGEMENTcommand, a command with the SATA PRIORITY bit set, or a command with anexecution time limit, might all be handled as high priority commands.The SAS protocol includes numerous types of SCSI queue managementcommands that might be handled as high priority commands.

FIG. 27 shows a block diagram of RXDP 306 that is adapted to detect andtrack high priority commands. As shown in FIG. 27, RXDP 306 includespriority command counter 2702. When a command is received and verifiedby RXDP 306, RXDP 306 moves the command from RX Buffer 308 to commandFIFO 323 maintained in, for example, at least one of buffer subsystem205 and context queue and buffer interface 2712 within command parser406. Commands are added to the tail of the FIFO as they are received,and commands are removed from the head of the FIFO as the commands areprocessed. When a PRIORITY (SATA) or HEAD OF QUEUE (SAS) command isadded to the tail of command FIFO 323, priority command counter 2702 isincremented, as indicated by increment control 2708. When prioritycommand counter 2702 is non-zero, an interrupt, 2706, is generated toindicate to processor 116 that a high priority command is in commandFIFO 323. Processor 116 then might process the priority command duringthe interrupt. When the priority command is processed, priority commandcounter 2708 is decremented, as indicated by decrement control 2704.Thus, multiple priority commands are received without interruptingprocessing of the previous priority command.

As described herein, SATA first party DMA (FPDMA) commands that have thePRIORITY bit set, and SAS commands that are IMPLICIT HEAD OF QUEUE orhave a Task Attribute that is HEAD OF QUEUE, are handled as highpriority commands. Priority command counter 2702 increments when RXDP306 moves a high priority command to the command queue. Priority commandcounter 2702 might also maintain status bits that indicate whether acommand was HEAD OF QUEUE (SAS) or PRIORITY (SATA). For example, forSAS, RXDP 306 might increment a HEAD OF QUEUE counter maintained inpriority command counter 2708 when a command is moved from RX Buffer 308if the command has the SAS Task Attribute field set to HEAD OF QUEUE,ORDERED or ACA, or if the command is an IMPLICIT HEAD OF QUEUE command.If these conditions are met, command parser 406 might set a status bitindicating a SAS priority command. For SATA, RXDP 306 might incrementthe Head of Queue counter maintained in priority command counter 2708when an FPDMA command is moved from RX Buffer 308 if the command has thePRIORITY bit set. If the PRIORITY bit is set, command parser 406 mightset a status bit indicating a SATA priority command.

In general, embodiments of the present invention process SATA and SASpriority commands similarly. For example, whenever a new command isadded to the command queue, processor 116 might check whether prioritycommand counter 2708 is greater than zero. If the counter is greaterthan zero, normal priority commands might be saved without creatingcontexts, instead generating contexts for the high priority command.

The SCSI command set supports command re-ordering with Task Attributesindicating ORDERED or HEAD OF QUEUE commands. In response to suchcommands, the command queue must be reordered to place the Ordered SCSIcommands ahead of other commands in the command queue. An interruptmight be generated when an ORDERED or HEAD OF QUEUE command is receivedand the number of ORDERED or HEAD OF QUEUE commands are tracked. Forexample, priority command counter 2708 might maintain a HEAD OF QUEUEcounter that is incremented every time an ORDERED or HEAD OF QUEUEcommand type is detected. Since the Task Attribute is embedded in thecommand, RXDP 306 might still write the command to the command queue andan interrupt is generated to indicate that a HEAD OF QUEUE command typehas been received. After handling the HEAD OF QUEUE command, the HEAD OFQUEUE counter is decremented. The HEAD OF QUEUE counter provides supportfor receiving multiple HEAD OF QUEUE command types before processing thefirst HEAD OF QUEUE interrupt.

After the HEAD OF QUEUE interrupt is generated and counter isincremented, command parser 406 might be frozen and RXDP 306 might stepthrough the commands stored in the command queue to find the HEAD OFQUEUE command. RXDP 306 might move the HEAD OF QUEUE command to commandparser 406 for processing, without changing the order of other commandsin the command queue. Thus, embodiments of the present inventionemploying an outstanding command FIFO provide support for processinghigh priority commands without changing the order of other commands inthe command queue.

As described herein, a context is a data structure that provides theinformation necessary to transmit or receive SAS frames or SATA FIS onthe bus. In embodiments of the present invention, contexts might begrouped into flow categories. Media controller data transfer performanceis generally important for data transfers, but other operations mightnot require high data transfer performance. For example, special typesof data transfers, such as negotiation of bus parameters or errorcorrection, might operate at lesser priority levels than data transfers,and be subject to higher latency than data transfers. However, specialtypes of transfers might require a higher degree of control over theframes that are transmitted. Embodiments of the present inventionprovide three data paths to generate SATA FIS or SAS frames: i)Automated Instruction Generation, ii) Non-Automated InstructionGeneration, and iii) Manual Frame Generation.

Approaches to context processing tend to be protocol-specific. Forexample, a SATA media controller might generate contexts containing allof the fields for an FIS, reducing processing performance by having acontext structure specific to the SATA protocol. Similarly, a SAS mediacontroller might employ SAS-specific context processing hardware, whichdoes not easily provide support for non-automated frames.

Automated Instruction Generation (AIG) mode provides a high performancepath for data transfers. In AIG mode, the context structure defines datablock structures that share a highly common structure between SATA andSAS. Context execution hardware implements the transfer protocol (e.g.SATA PIO mode, SATA DMA mode, SATA NCQ mode, SAS, etc.). Information inone context is employed to transfer a series of one or more frames oncommunication link 102 in conformance with the appropriate protocol. ForAIG mode, firmware running on processor 116 breaks up commands basedupon the setup frame requirements for the protocol. Processor 116programs high level information about the transfer, such as theprotocol, the amount of data, response requirements at the end of thecommand, etc.

For the data performance path (e.g., RXDP 306 and TXDP 318), themajority of context fields are shared between the SATA protocol and theSAS protocol. Thus, context data structures might be substantiallyequivalent for the SAS protocol and the SATA protocol, allowing forincreased design flexibility. For example, typical data stored within acontext might include: context configuration data, pointers to a nextcontext for the data transfer and the buffer location of the data totransfer, the total length of the data transfer, an offset representingthe location of the data transfer if the transfer is not aligned toboundaries of the buffer, and the logical block address (LBA) of thedata transfer. Contexts might also include other status data to bepassed between processing modules of media controller 104. Inembodiments of the present invention, contexts might typically include12 32-bit datawords. AIG mode will be described in greater detail inregard to FIG. 28.

Non-Automated Instruction Generation (NAIG) mode provides control overthe fields in the frames. In this mode, context fields might corresponddirectly to frame fields, and, further, single contexts might correspondone-to-one with single frames. Thus, a context exists for eachtransferred frame. A non-automated instruction thus might cause one FISor frame to be transmitted. NAIG mode advantageously provides greatercontrol over fields within the frame, for example, in NAIG mode,firmware running on processor 116 might have control over one or morefields within each type of FIS. NAIG mode might be employed for lowerperformance transfers, such as error handling or transfers where morecontrol of protocol fields is required. This allows greater designflexibility in response to changes in protocol specifications for futuremode support. A non-automated instruction is used, for example, to sendstatus at the end of a command that failed.

Non-automated instruction generation gives firmware running on processor116 control over most fields in each type of FIS. Non-automatedinstruction generation might be used, for example, to send status at theend of a command that failed. Contexts are queued, with each contextgenerating one FIS.

Manual Frame Generation (MFG) builds one frame in a buffer and issues acontext corresponding to this one frame. Firmware running on processor116 has full control over generation of the frame. Thus, in MFG,firmware builds all datawords of a FIS or frame in the buffer. Firmwarethen creates a buffer context that indicates to send a manual FIS/frame,and that contains the buffer address for the FIS/frame and the length ofthe FIS/frame. This frame is then transmitted from the buffer and ontothe bus. MFG generally will not be used, but could be employed toprovide vendor specific frame(s) that might not be defined in a standardprotocol, and further allows for generation of customized testsequences. Thus, as described herein, embodiments of the presentinvention provide common context fields that can be applied tomultiple-frame bus transfers to facilitate fast bus transfers. Ahigh-level context structure allows firmware running on processor 116 togenerally be independent of protocol details for data block transfersbecause the majority of contexts are similar between SATA and SASprotocols. A non-automated context flow provides control of individualframe fields.

Instruction interface 314 processes protocol commands, issuinginstructions to link protocol core 304 to transmit FIS (SATA protocol)or frames (SAS protocol) and to handshake with a host device incommunication with communication link 102. Contexts provide theinformation to instruction interface 314 necessary to process protocolcommands. Firmware running on processor 116 creates and writes theseinto linked lists in context buffer 322. Context Cache 408 loads eachcontext in the linked list, and passes the context to instructioninterface 314 for execution. Instruction interface 314 is also incommunication with RXDP 306 and pending write table 324. The path fromRXDP 306 to instruction interface 314 provides support for SATA FPDMAcommands (e.g. to transmit a register FIS clearing busy). The path frompending write table 324 is used to transmit a response after write datahas been received by media controller 104. As described in regard toFIG. 9, instruction interface 314 for the SAS protocol includes a fewadditional modules versus instruction interface 314 for the SATAprotocol. For example, for SAS protocol support, additional modules suchas PWT 324 and initiator lookup table 404 are in communication withinstruction interface 314. Instruction interface 314 includes a statemachine to process frames as necessary to fulfill the protocolrequirements. Block based data transfer commands are handed usingautomated instruction generation.

For example, media controller 104 might be in communication with a SATAdevice and receive a command to transmit 8 blocks of data using the SATAFPDMA (NCQ) protocol. As will be described with respect to FIG. 28, theSATA protocol for this transfer is for the device to transmit a DMASETUP FIS, and then to transmit pairs of DMA Activate and Data FIS untilall data has been transmitted, at which point a SetDeviceBits FIS istransmitted as a response. In embodiments of the present invention, onecontext is generated to transmit both the data and the response. Detailsof the transmitted FIS, such as entries placed in the DMA BufferIdentifier field of a DMA SETUP FIS, are handled by automated hardware.

FIG. 28 shows state machine 2800 of instruction interface 314 toautomatically create any necessary FIS to complete the contextprocessing for an exemplary SATA FPDMA request. As shown in FIG. 28,there are seven possible states that might exist in the processing of acontext by instruction interface 314: idle (state 2802), SETUP FIS(state 2804), activate FIS (state 2806), RX data (state 2808), TX data(state 2810), status FIS (state 2812), and clear context and command tag(state 2814). In general, the state machine is at idle (state 2802), andmaintains this state, as shown by state transition 1, until a context isprovided to instruction interface 314 to process a SATA FPDMA request.Once a context is provided to instruction interface 314 to process aSATA FPDMA request, instruction interface 314 proceeds to SETUP FISstate 2804, as indicated by state transition 2, and a context indicatinginformation to be sent in a FIS is generated in context buffer 322.Based on this context, instruction interface 314 generates the FIS dataand transfers the FIS data to link protocol core 304 to generate andtransmit the FIS. If the SATA FPDMA request is a write data request,instruction interface 314 proceeds to activate FIS state 2806, asindicated by state transition 5. At activate FIS state 2806, a DMAactivate FIS is transferred to link protocol core 304. As indicated bystate transitions 12 and 13, instruction interface 314 transitionsbetween RX data state 2808 and activate FIS state 2806 until all thedata of the write data request is received by host subsystem 201. Onceall the data of the write data request is received, instructioninterface 314 proceeds to status FIS state 2812, as indicated by statetransition 9. At status FIS state 2812, a status FIS is transferred tolink protocol core 304.

Once the status FIS is processed, instruction interface 314 proceeds toclear context and command tag state 2814, as indicated by statetransition 11. At clear context and command tag state 2814, instructioninterface 314 clears its context, and the command tag is cleared fromtag manager 402. After the context and command tag are cleared,instruction interface 314 returns to idle state 2802, as indicated bystate transition 4.

If the SATA FPDMA request is a read data request, instruction interface314 proceeds from SETUP FIS state 2804 to TX data state 2810, asindicated by state transition 6. At TX data state 2810 the context forthe entire data transfer is processed. After all the data of the readrequest is transferred, as indicated by state transition 8.Alternatively, the command tag might be cleared, as indicated by statetransition 10. Once the status FIS is processed, instruction interface314 proceeds to clear context and command tag state 2814, as indicatedby state transition 11. At clear context and command tag state 2814,instruction interface 314 clears its context and clears the command tagfrom tag manager 402. After the command tag is cleared, instructioninterface 314 returns to idle state 2802, as indicated by statetransition 4. Also, as indicated by state transition 3, instructioninterface 314 might proceed from idle state 2802 to clear context andcommand tag state 2814, for example, to clear a context for an abortedtransfer. As indicated by state transition 7, a status FIS might be sentany time a data transfer or other command completes without error. Thus,instruction interface 314 transmits the necessary Setup or Activate FIS,transmits one or more data FIS, transmits a FIS to indicate good statusat the end of a command, deletes the command tag at the end of thecommand, and optionally recycles the context pointer after each contexthas completed.

Embodiments of the present invention provide six automated FIS sequencesfor the SATA protocol: Auto-Status, DMA data transfer, PIO datatransfer, PIO Multiple Mode, FPDMA Queued Commands, and FPDMA Queueddata transfers. Instruction interface 314 automatically formats andsends an auto-status FIS after a read data transfer completes withouterror. The auto-status FIS is a register FIS for PIO and DMA readcommands, and is a Set Device Bits FIS for FPDMA Queued read or writecommands (e.g., state 2812). The automated DMA data transfer sequenceautomatically controls a DMA data transfer, including sending the DMAactivate FIS (e.g., state 2806), data transfer FIS (e.g., states 2808and 2810), and status FIS (e.g., state 2812). The context stored incontext buffer 322 indicates the data transfer amount and control bitsfor desired protocol sequence, and instruction interface 314automatically steps through the DMA sequence (e.g., DMA Activate forwrite, transfer data FIS, repeat until data transfer is complete, thensend status for read, as shown in FIG. 28).

The automated PIO Data Transfer sequence automatically controls PIO datatransfers, including sending the PIO SETUP FIS, the data transfer FIS,and the status FIS for a read command. The context stored in contextbuffer 322 indicates the data transfer amount and control bits fordesired protocol sequence. Similarly as described for the automated DMAdata transfer shown in FIG. 28, instruction interface 314 automaticallysteps through the PIO sequence (PIO SETUP FIS, data transfer FIS, repeatuntil transfer is complete, status FIS). The automated PIO Multiple Modeautomatically combines contexts to transfer multiple blocks in a singleFIS. As described with regard to FIGS. 14-16, separate contexts might beemployed for the PIO SETUP FIS and subsequent data transfer contexts.

After receipt of FPDMA Queued Command, the automated FPDMA QueuedCommand sequence automatically verifies the command FIS and the FIS tagand sends the Register FIS to clear the BUSY bit for that receivedcommand. The automated FPDMA Queued Data Transfer sequence automaticallycontrols FPDMA Queued data transfers including sending the DMA SETUPFIS, the DMA activate FIS, the data transfer FIS, and the status FIS.The context stored in context buffer 322 indicates the data transferamount and control bits for desired protocol sequence. Similarly asdescribed for the automated DMA data transfer shown in FIG. 28,instruction interface 314 automatically steps through the FPDMA sequence(DMA SETUP FIS, DMA Activate FIS, transfer data FIS, repeat until datatransfer is complete, status FIS). Individual contexts might be splitinto one or more smaller contexts to control individual steps in thesequence if necessary. As described with regard to FIGS. 14-16, separatecontexts might be employed for the DMA Setup Context and one or moresmaller data transfer contexts.

Embodiments of the present invention provide automatic generation of SASprotocol frames, similarly as described for SATA protocol FIS.Instruction interface 314 might automate read and write sequences suchthat the context stored in context buffer 322 only needs to indicate theoverall length of the data transfer, and include appropriate protocolcontrol bits. For example, instruction interface 314 might automaticallyissue a SAS connection frame if a connection is currently notestablished which provides connection information to link protocol core304 to verify and establish a connection with a SAS host device viacommunication link 102. Instruction interface 314 might alsoautomatically format and send a status frame after a data transfercompletes without error. Further, read and write transfer frames mightalso be automatically generated. For example, for a read data transfer,instruction interface 314 might automatically issue an instruction formultiple data frames and send the status frame once the transfer iscomplete. Similarly, for a write data transfer, instruction interface314 might automatically send the TRANSFER READY frame, receive writedata frames, and send a status frame at the end of the transfer (ifwrite caching is enabled). As described herein, multiple outstandingwrite streams are supported by employing Pending Write Table 324.

SATA compliant media controllers support Native Command Queuing (NCQ).NCQ generally allows the media controller to control the order in whichreceived read and write commands are performed. This might reduce theamount of drive head movement to process the received commands,resulting in increased performance for workloads that have multiplesimultaneous read/write requests outstanding. NCQ allows for up to 32commands to be queued and active at the same time. The SATA protocoluses First Party DMA (FPDMA) commands for NCQ.

NCQ requires a specific handshaking protocol after an FPDMA command istransmitted by a host. The handshake requires that the device transmit aDevice-to-Host FIS to clear the SATA BUSY bit, which releases the busafter the FPDMA command is received. Handshaking to release the busmight create a bottle neck in systems handling multiple queued commands.For example, for NCQ, the host transmits a Host-to-Device Register FIScontaining an FPDMA write or read command. The SATA busy bit (BSY) isset to indicate that the drive is busy. After the media controllerreceives the command with no errors, the device releases the bus (e.g.,communication link 102) by transmitting a Device-to-Host Register FISwith BSY set to 0. Once the bus is released, the host can transmit a newFPDMA command, or the media controller can return data for previouslyqueued commands.

Embodiments of the present invention provide that handshaking is handledin hardware, which reduces the delay in transmitting the FIS versushandling the handshaking in firmware, and also reduces the workload ofprocessor 116. Specifically, RXDP 306 parses the incoming Register FISto recognize FPDMA commands used for NCQ, routes the incoming RegisterFIS to a command queue, interrupts firmware when the command is queued,automatically performs context execution, and then instruction interface314 transmits the Register FIS, which completes the handshake andreleases the bus. By releasing the bus sooner, the bus is free fortransmission of additional data, improving overall system performance,and by reducing demand on processor 116, the processor is available toprocess the current command, rather than processing SATA protocolrequirements. Finally, by removing protocol details from firmware, theresulting firmware is similar for both SATA and SAS.

RXDP 306 parses the incoming FIS. If the FIS is a Register FIScontaining an FPDMA command, a plurality of checks is performed on theFIS. For example, link protocol core 304 verifies that the FIS has noLink Layer violations, and writes the FIS into a receive buffer (e.g.,RX buffer 308). RXDP 306 performs additional checks on the FIS,verifying the command, verifying the tag, and adding the tag to a tagmanager (e.g., tag manager 402). As described herein, a command tag is aunique ID assigned to commands (e.g., SATA NCQ tags range from 0-31, SAStags have a 16 bit value). Tag manager 402 stores a list of activecommand tags and checks for tag overlap when new commands are received.RXDP 306 requests that instruction interface 314 transmit the RegisterFIS to clear busy bit and release the bus. RXDP 306 and instructioninterface 314 have an interlock to allow instruction interface 314 totransmit the Register FIS immediately after an FPDMA command is receivedand the tag is added to the tag manager.

The interlock is set when link protocol core 304 writes the firstdataword of an FIS into RX buffer 308 and the interlock is cleared whenthe last dataword is removed from RX buffer 308. When the interlock isset, instruction interface 314 generally does not load a new contextfrom context cache 408. If instruction interface 314 already has acontext loaded, then instruction interface 314 sends the data transfercorresponding to the context to link protocol core 304 for transfer tocommunication link 102. Once the data transfer is sent to link protocolcore 304, instruction interface 314 transmits the Register FIS.Embodiments of the present invention thus provide support for SATANative Command Queuing (NCQ).

As described herein, embodiments of the present invention provide amedia controller for servicing contexts corresponding to data transferrequests from host devices. The media controller includes a contextgenerator for generating contexts corresponding to the data transferrequests and a buffer for storing one or more context pointers, eachpointer corresponding to a context and an action by a system moduleassociated with the context. A context processor is configured tocomplete a context when the action by a media controller moduleassociated with the context is complete, remove each pointer from thebuffer associated with the completed context, and determine whether aninterrupt corresponds to the completed context and removed pointer. Ifno interrupt corresponds to the completed context, the completed contextis cleared. If an interrupt corresponds to the completed context, theinterrupt is provided to a master processor and a completed contextrecycler for recycling the completed context pointer to the contextgenerator.

Reference herein to “one embodiment”, “an exemplary embodiment”, or “anembodiment” means that a particular feature, structure, orcharacteristic described in connection with the embodiment can beincluded in at least one embodiment of the invention. The appearances ofthe phrase “in one embodiment” in various places in the specificationare not necessarily all referring to the same embodiment, nor areseparate or alternative embodiments necessarily mutually exclusive ofother embodiments. The same applies to the term “implementation.”

While the exemplary embodiments of the present invention have beendescribed with respect to processing blocks in a software program,including possible implementation as a digital signal processor,micro-controller, or general purpose computer, the present invention isnot so limited. As would be apparent to one skilled in the art, variousfunctions of software might also be implemented as processes ofcircuits. Such circuits might be employed in, for example, a singleintegrated circuit, a multi-chip module, a single card, or a multi-cardcircuit pack.

The present invention can be embodied in the form of methods andapparatuses for practicing those methods. The present invention can alsobe embodied in the form of program code embodied in tangible media, suchas magnetic recording media, optical recording media, solid statememory, floppy diskettes, CD-ROMs, hard drives, or any othernon-transitory machine-readable storage medium, wherein, when theprogram code is loaded into and executed by a machine, such as acomputer, the machine becomes an apparatus for practicing the invention.The present invention can also be embodied in the form of program code,for example, whether stored in a non-transitory machine-readable storagemedium, loaded into and/or executed by a machine, or transmitted oversome transmission medium or carrier, such as over electrical wiring orcabling, through fiber optics, or via electromagnetic radiation,wherein, when the program code is loaded into and executed by a machine,such as a computer, the machine becomes an apparatus for practicing theinvention. When implemented on a general-purpose processor, the programcode segments combine with the processor to provide a unique device thatoperates analogously to specific logic circuits. The present inventioncan also be embodied in the form of a bitstream or other sequence ofsignal values electrically or optically transmitted through a medium,stored magnetic-field variations in a magnetic recording medium, etc.,generated using a method and/or an apparatus of the present invention.

It should be understood that the steps of the exemplary methods setforth herein are not necessarily required to be performed in the orderdescribed, and the order of the steps of such methods should beunderstood to be merely exemplary. Likewise, additional steps might beincluded in such methods, and certain steps might be omitted orcombined, in methods consistent with various embodiments of the presentinvention.

As used herein in reference to an element and a standard, the term“compatible” means that the element communicates with other elements ina manner wholly or partially specified by the standard, and would berecognized by other elements as sufficiently capable of communicatingwith the other elements in the manner specified by the standard. Thecompatible element does not need to operate internally in a mannerspecified by the standard.

Also for purposes of this description, the terms “couple,” “coupling,”“coupled,” “connect,” “connecting,” or “connected” refer to any mannerknown in the art or later developed in which energy is allowed to betransferred between two or more elements, and the interposition of oneor more additional elements is contemplated, although not required.Conversely, the terms “directly coupled,” “directly connected,” etc.,imply the absence of such additional elements. Signals and correspondingnodes or ports might be referred to by the same name and areinterchangeable for purposes here.

It will be further understood that various changes in the details,materials, and arrangements of the parts which have been described andillustrated in order to explain the nature of this invention might bemade by those skilled in the art without departing from the scope of theinvention as expressed in the following claims.

We claim:
 1. A method of servicing contexts generated by a contextgenerator, the method comprising: storing one or more context pointersin a buffer, each pointer corresponding to a context and an action by asystem module associated with context; completing a context whencompleting the action by the system module associated with the context;removing each pointer from the buffer associated with the completedcontext; determining whether an interrupt corresponds to the completedcontext and removed pointer; and if no interrupt corresponds to thecompleted context, clearing the completed context; and if an interruptcorresponds to the completed context, providing the interrupt to amaster processor; reading, by the master processor, the completedcontext associated with the interrupt; processing, by the masterprocessor, data of the completed context; and clearing the context andthe interrupt.
 2. The method as recited in claim 1, comprising recyclingthe completed context pointer to the context generator when no interruptcorresponds to the completed context.
 3. The method as recited in claim1, further comprising recycling the completed context pointer to thecontext generator.
 4. The method as recited in claim 1, furthercomprising updating system performance statistics when processing thecompleted context.
 5. The method as recited in claim 1, wherein, for aplurality of completed contexts, the removing each pointer includesremoving each pointer in an order of completion for the plurality ofcompleted contexts.
 6. The method as recited in claim 1, wherein themethod is implemented by a consumed context manager of a mediacontroller.
 7. A non-transitory machine-readable storage medium, havingencoded thereon program code, wherein, when the program code is executedby a machine, the machine implements a method of servicing contextsgenerated by a context generator, the method comprising: storing one ormore context pointers in a buffer, each pointer corresponding to acontext and an action by a system module associated with context;completing a context when completing the action by the system moduleassociated with the context; removing each pointer from the bufferassociated with the completed context; determining whether an interruptcorresponds to the completed context and removed pointer; and if nointerrupt corresponds to the completed context, clearing the completedcontext; and if an interrupt corresponds to the completed context,providing the interrupt to a master processor; reading, by the masterprocessor, the completed context associated with the interrupt;processing, by the master processor, data of the completed context; andclearing the context and the interrupt.
 8. The machine-readable storagemedium as recited in claim 7, comprising recycling, the completedcontext pointer to the context generator when no interrupt correspondsto the completed context.
 9. The machine-readable storage medium asrecited in claim 7, further comprising recycling the completed contextpointer to the context generator.
 10. The machine-readable storagemedium as recited in claim 7, further comprising updating systemperformance statistics when processing the completed context.
 11. Themachine-readable storage medium as recited in claim 7, wherein, for aplurality of completed contexts, the removing each pointer includesremoving each pointer in an order of completion for the plurality ofcompleted contexts.
 12. The machine-readable storage medium as recitedin claim 7, wherein the method is implemented by a consumed contextmanager of a media controller.
 13. A media controller for servicingcontexts corresponding to data transfer requests from host devices, themedia controller comprising: a context generator for generating contextscorresponding to the data transfer requests; a buffer for storing one ormore context pointers, each pointer corresponding to a context and anaction by a system module associated with context; a context processorconfigured to: (i) complete a context when the action by a mediacontroller module associated with the context is complete; (ii) removeeach pointer from the buffer associated with the completed context;(iii) determine whether an interrupt corresponds to the completedcontext and removed pointer; and (iv) if no interrupt corresponds to thecompleted context, clear the completed context; and if an interruptcorresponds to the completed context, provide the interrupt to a masterprocessor; and a completed context recycler for recycling the completedcontext pointer to the context generator when no interrupt correspondsto the completed context; wherein, if an interrupt corresponds to thecompleted context, the master processor is configured to (i) read thecompleted context associated with the interrupt; (ii) process data ofthe completed context; and (iii) clear the context and the interrupt.14. The media controller as recited in claim 13, wherein the masterprocessor is further configured to (i) recycle the completed contextpointer to the context generator; and (ii) update system performancestatistics when processing the completed context.
 15. The mediacontroller as recited in claim 13, wherein the media controller iscoupled to a storage media comprising a Redundant Array of IndependentDisks (RAID) array.
 16. The media controller as recited in claim 13,wherein the RAID array comprises at least one of a solid state disk(SSD), a hard disk drive (HDD), or a hybrid magnetic and solid statestorage system.
 17. The media controller as recited in claim 13, whereinthe media controller is implemented in an integrated circuit.